how to convert image in rectangle into gray??
Hello,
I am looking for logic or suggestions regarding to access the or do various operations with selected rectangles from the image. for example in given image I am able to draw rectangle by using rectangle function but I want to convert the selected rectangle parts into gray scale or to find the non zero element values for it.
for (int i = 612; i >= 0; i = i-204)
{
cout << "i" << i << endl;
rectangle( roi1, Rect(i, 0, 161, 643), (255, 255,255), 2, 8, 0 );//add this line to draw contour on main screen
}
imshow( "Display window", roi1 );
Is there any suggestions how can I do so?
Thank you very much in advance.
Regards.
you can crop the region of interest from the original image with
and then convert it to grayscale as usual with
Thank you very much for suggestion. I tried with following code, But still I am not getting the result. Mat OI = imread("C:/Users/ankit/Desktop/New folder/2/cam2.png", 1);
Mat roi2 = OI.clone();
for (int i = 612; i >= 0; i = i-204) { cout << "i" << i << endl; Mat roi2 = OI(Rect(i, 0, 161, 643)); rectangle( OI, Rect(i, 0, 161, 643), 1, 2, 8, 0 );
imshow("Display window",roi2);
if possible then please provide me simple code or suggestion again.
Thank you very much once again.
hello, I want to perform operation in the same image. Thank you very much.