Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

:)

이동 변환과 전단 변환 본문

컴퓨터비전

이동 변환과 전단 변환

mihee 2022. 3. 22. 10:58

영상의 기하학적 변환(geometric transformation)

  • 영상을 구성하는 픽셀의 배치 구조를 변경(픽셀의 위치를 변경)함으로써 전체 영상의 모양을 바꾸는 작업
  • 전처리 작업, 영상 정합(image registration), 왜곡 제거 등

1이라는 좌표는 없는 좌표인데 수식 전개의 편의를 위해서 표현

int main()
{
	Mat src = imread("lenna.bmp", IMREAD_GRAYSCALE);

	if (src.empty()) {
		cerr << "Image laod failed!" << endl;
		return -1;
	}

	Mat dst = Mat::zeros(src.rows, src.cols, CV_8UC1);	// 검은색 픽셀 값 0으로 채워져있는 영상을 만들어줌.

	for (int y = 0; y < src.rows; y++) {
		for (int x = 0; x < src.cols; x++) {
			// x` = x + a, y` = y + a (x,y : 원본영상, x`,y`:결과영상)
			int x_ = x + 200;
			int y_ = y + 200;
			if (x_ >= dst.cols) continue;
			if (y_ >= dst.rows) continue;
			dst.at<uchar>(y_,x_) = src.at<uchar>(y, x);
		}
	}
	imshow("src", src);
	imshow("dst", dst);
	waitKey();
}

src : 원본영상, dst : 결과영상

 

Mat dst(src.rows * 3 / 2, src.cols, src.type(), Scalar(0));

	double m = 0.5;
	for (int y = 0; y < src.rows; y++) {
		for (int x = 0; x < src.cols; x++) {
			int nx = x;
			int ny = int(y + m*x);
			dst.at<uchar>(ny, nx) = src.at<uchar>(y, x);
		}
	}

'컴퓨터비전' 카테고리의 다른 글

회전 변환과 기하학적 변환의 조합  (0) 2022.03.22
크기변환과 보간법  (0) 2022.03.22
영상처리_필터링  (0) 2022.03.21
OpenCV 함수  (0) 2022.03.20
이벤트 처리하기  (0) 2022.03.19
Comments