jana radha
jana radha

Reputation: 13

How to flip particluar part of images with angled rectangle or any other angle shapes in open cv c++

I need flip the particular part of image in opencv.I searched enough but i got only cv::flip() method to flipped the entire image, how can i flip certain part of image from a image by angled rect or any other angle shapes.

cv::Mat src=imread("memory.png");
cv::Mat dst;             
cv::flip(src, dst, 1); 

Above code used to flip entire image. but i need to flip certain part of image by angle.

Upvotes: 1

Views: 531

Answers (2)

siahlooei
siahlooei

Reputation: 11

You can use region or ROI in opencv. All operation in your image can apply in regions.

This block of code can be helpful.

dst = src;
cv::Mat subImg = dst(cv::Range(0, 100), cv::Range(0, 100));
cv::flip(subImg , subImg , 1); 

Note : I didn't test above code.

Upvotes: 0

Adi Shavit
Adi Shavit

Reputation: 17265

Assuming you mean an axis aligned rectangular region, you need to define a ROI - Region-of-Interest.
You do this using cv::Ranges on the columns and rows, or with the cv::Rect ctor/operator.

For example:

cv::Mat src=imread("memory.png");
auto roi = cv::Rect(10,10,50,50);// ROI origin is at (10,10) with size 50x50
cv::flip(src(roi), src(roi), 1); // Apply flip operation only inside ROI

Upvotes: 1

Related Questions