Using ROI for partial image processing

Ask question on using Emgu CV with C#
Post Reply
hsribeiro
Posts: 1
Joined: Tue Feb 11, 2020 7:14 am

Using ROI for partial image processing

Post by hsribeiro » Tue Feb 11, 2020 7:45 am

Hi guys!

I'm new in Emgu and I started using VC# with Visual Studio.
I have a strange problem! I'm using a 20MPx camera, so the image is huge, and when I used a Canny algorithm the process time was very high.
To solve these problem I used ROI's but now I have this problem:

I have a Rectangle array (for now I just test the first element), and with this rectangle I define Roi in my input image imgROI (copy of original imgGray).
Then I define with the same rectangle the ROI of imgAllArea (output image).
Then I apply the Canny algorithm (and some algorithms before that) and there is no error.
I saw the result in a imshow window ("ROI2") and I have the desired edges.
But when I reset the ROI (Rectangle.Empty) and get the image in full size in a imageBox, (most of the times but not always), In the area of the ROI I dont have nothing.
I can't understand this behavior, and I can't get in wich conditions this proceder works or not.

Anyone have some clue about this??

Thanks!

Code: Select all

	    Image<Gray, byte> imgROI = imgGray.ToImage<Gray, byte>();
            Image<Gray, byte> imgAllArea = imgROI.CopyBlank();

            int auxInt = 0;
            aux_bool = false;
            foreach (Rectangle rectangle in searchArea)
            {
                    auxInt++;

                imgROI.ROI = rectangle;
                imgAllArea.ROI = rectangle;
                CvInvoke.PyrDown(imgROI, pyrDown);
                CvInvoke.PyrUp(pyrDown, imgROI);

                CvInvoke.Canny(imgROI, imgAllArea, minTresh, maxTresh, 7, true);
                if (!aux_bool)
                {
                    aux_bool = true;
                    CvInvoke.DestroyWindow("ROI2");
                    CvInvoke.Imshow("ROI2", imgAllArea);
                }
                imgROI.ROI = Rectangle.Empty;
                imgAllArea.ROI = Rectangle.Empty;
                if (auxInt == 1)
                    break;
            }
            imboxResult.Image = imgAllArea.Clone();
            return;
            

Post Reply