I have 2 (aerial) images, taken from a slightly different angle:
I need to rescale image1 in horizontal direction to align it to image2. Without any modification, both images placed next to each other look like this:
This is the desired result: (made with photoshop)
In Photoshop, I took the right half of image1 and scaled it down horizontally a little bit. I did the same for the left half of image1, where I had to scale slightly more.
I would like to know how I can accomplish this using openCV - by using Hough Line Transform. I already started drawing hough lines, but I have no idea how to do the transform to make the hough lines match:
Here's my C++ code (called from objective-c):
cv::Mat image1 = [im1 CVMat3];
cv::Mat gray_image1;
// Convert to Grayscale
cvtColor( image1, gray_image1, CV_RGB2GRAY );
cv::Mat dst1, cdst;
Canny(image1, dst1, 40, 90, 3);
double minLineLength = 0;
double maxLineGap = 10;
std::vector<cv::Vec2f> lines;
// detect lines
cv::HoughLines(dst1, lines, 1, CV_PI/180, 90, minLineLength,maxLineGap );
for( size_t i = 0; i < lines.size(); i++ ) {
float rho = lines[i][0], theta = lines[i][1];
if( theta>CV_PI/180*70 && theta<CV_PI/180*110) {
cv::Point pt1, pt2;
double a = cos(theta), b = sin(theta);
double x0 = a*rho, y0 = b*rho;
pt1.x = cvRound(x0 + 1000*(-b));
pt1.y = cvRound(y0 + 1000*(a));
pt2.x = cvRound(x0 - 1000*(-b));
pt2.y = cvRound(y0 - 1000*(a));
line( image1, pt1, pt2, cvScalar(10,100,255), 3, CV_AA);
}
}
Some help would be really appreciated :-). Thanks in advance.