보간없이 왜곡되지 않은 이미지를 얻으려고 많은 노력을했습니다. 그러나 아래 코드를 실행하면 이상한 이미지가 나옵니다. init_ndistortRectifyMap 함수를 사용하여 mapx와 mapy에 CV_16SC2 타입의 mapy를 나중에 convertMaps 함수를 사용하여 제공합니다. mapx와 mapy를 CV_32FC1로 변환합니다. 이유는 없지만 도움이 될만한 것을 찾지 못했습니다.보간없이 왜곡되지 않은 이미지를 얻는 방법
왜곡 된 이미지 화상 (j, I) = cf1.at (mapy.at (j undistorted.at 코드 이 버전 보간없이
int main()
{
Mat Cam1MatrixParam, Cam1Distortion;
Mat cf1;
cf1=imread("cam1.distort1.jpg", CV_LOAD_IMAGE_COLOR);
Size imagesize = cf1.size();
FileStorage fs1("cameracalibration.xml", FileStorage::READ);
fs1["camera_matrix"] >> Cam1MatrixParam;
fs1["distortion_coefficients"] >> Cam1Distortion;
Mat R = Mat::eye(3, 3, CV_32F) * 1;
int width = cf1.cols;
int height = cf1.rows;
Mat undistorted = Mat(height, width, CV_8UC3);
Mat mapx = Mat(height, width, CV_32FC1);
Mat mapy = Mat(height, width, CV_32FC1);
initUndistortRectifyMap(Cam1MatrixParam, Cam1Distortion, Cam1MatrixParam, R, imagesize, CV_16SC2, mapx, mapy);
convertMaps(mapx, mapy, mapx, mapy, CV_32FC1, false);
for (int j = 0; j < height; j++)
{
for (int i = 0; i < width; i++)
{
undistorted.at<uchar>(mapy.at<float>(j, i), mapx.at<float>(j, i)) = cf1.at<uchar>(j, i);
}
}
imwrite("cam1.undistortimage.png", undistorted);
}
화상 undistort 적용 후 , i), mapx.at (j, i)); undistort 기능 (가까운 보간 리맵)와
어쩌면 당신은 이력서 :: 다시 매핑을 사용할 수 있습니다 CV_INTER_NN을 사용하여 보간 대신 가장 가까운 픽셀을 선택 하시겠습니까? – Micka
예. 가장 가까운 보간법이 선형 보간법보다 두 배 빠르기 때문에 이미 해왔습니다. – Reddy2810
그래서 "보간법 없음"에 대해 이야기한다면 다른 무엇을 기대합니까? – Micka