Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Copy image using Rect() and copyTo()

I followed the tutorial about dft and it worked. But I tried to remake it to a class. Small changes I did. In the tutorial the are the square if images swapped and I do not want them to be swapped. I have changed the names of variables and this is what I have:

cv::Mat tl(logScaled, Rect(0, 0, half_width, half_height)); // Top-Left - Create a ROI per quadrant
cv::Mat tr(logScaled, Rect(cx, 0, half_width, half_height)); // Top-Right
cv::Mat bl(logScaled, Rect(0, cy, half_width, half_height)); // Bottom-Left
cv::Mat br(logScaled, Rect(cx, cy, half_width, half_height)); // Bottom-Right
tl.copyTo(Images[file_no]);
tr.copyTo(Images[file_no]);
bl.copyTo(Images[file_no]);
br.copyTo(Images[file_no]);
cv::normalize(Images[file_no], Images[file_no], 0, 1, NORM_MINMAX); 
cv::imshow("spectrum magnitude", Images[file_no]);
cv::waitKey();

Only 1/4 of the image is displayed so I think it is the top left (or bottom right?) square. How to complete this successfully to copy all the 4 squares/images to the image? Images[file_no] keeps the original image untill I copy the squares onto it. It looks like the header is overwritten but how to solve it?