Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Copying parts of image to new images?

This is what I am trying to accomplish:

User loads original image, which is displayed User selects ROI (as rectR, below) ROI only is displayed separately ROI is processed Processed ROI is displayed separately

In other words, there are 3 separate images (original, rectROI and ROIMarked) . Since "ROI only" is a copy of part of the original, it could theoretically be done with a separate headed, except that the ROI must be on a 4-byte boundary for easy display in Windows.

By trial-and-error, this is what I came up with that works:

Mat original=imread((LPCTSTR)ar.m_strFileName); // original
Mat temp1=original.clone();
Mat temp2(temp1, rectR);
Mat rectROI=temp2.clone();                     // ROI only
Mat ROIMarked=rectROI.clone();                 // ROI processed

But I feel there must be a more elegant (and efficient) method. How can I create rectROI and ROIMarked from original, as separate images (i e, data not shared)?

OpenCV 2.?, 64-bit Windows 7, C++

Copying parts of image to new images?

This is what I am trying to accomplish:

User loads original image, which is displayed User selects ROI (as rectR, below) ROI only is displayed separately ROI is processed Processed ROI is displayed separately

In other words, there are 3 separate images (original, rectROI and ROIMarked) . Since "ROI only" is a copy of part of the original, it could theoretically be done with a separate headed, except that the ROI must be on a 4-byte boundary for easy display in Windows.

By trial-and-error, this is what I came up with that works:

Mat original=imread((LPCTSTR)ar.m_strFileName); // original
Mat temp1=original.clone();
Mat temp2(temp1, rectR);
Mat rectROI=temp2.clone();                     // ROI only
Mat ROIMarked=rectROI.clone();                 // ROI processed

But I feel there must be a more elegant (and efficient) method. How can I create rectROI and ROIMarked from original, as separate images (i e, data not shared)?

OpenCV 2.?, 64-bit Windows 7, C++