0

I am a beginner in image processing especially in openCV C++. I have a problem on my work. In C# with EmguCV it is possible to make masking in image and video files based on ROI. My question is, is it possible to make masks the same way in OpenCV C++? . I have tried to use ROI in OpenCV C++, but the result only cropping the image not like the example that i attached Here. I also attached the pseucode of masking in C# with EmguCV but have not found yet in C++ version. I am looking forward for any answer. Thank You

pixelSize, out long processingTime)
    {


        int x = imageInput.Width / pixelSize;
        int y = imageInput.Height / pixelSize;

        Mat imageBlock = new Mat();
        Point darkestBlockPoint = new Point();

        int darkestBlockValue = 100000;
        //AppendLogTxt("", "y,x,value", "masking");
        for (int i = marginV; i < y - marginV; i++)
        {
            for (int j = marginH; j < x - marginH; j++)
            {
                imageBlock = new Mat(imageInput, new Rectangle(j * pixelSize, i * pixelSize, pixelSize, pixelSize));
                MCvScalar avg = CvInvoke.Mean(imageBlock);

                //AppendLogTxt("", i.ToString() + "," + j.ToString() + "," + avg.V0.ToString(), "masking");

                if ((int)avg.V0 < darkestBlockValue)
                {
                    darkestBlockValue = (int)avg.V0;
                    darkestBlockPoint.X = j;
                    darkestBlockPoint.Y = i;
                }

            }
        }

        darkestBlockPoint.X = darkestBlockPoint.X * pixelSize + pixelSize / 2;
        darkestBlockPoint.Y = darkestBlockPoint.Y * pixelSize + pixelSize / 2;

        return darkestBlockPoint;
    }
Kaiwen
  • 137
  • 1
  • 9
  • If I understand well, you want to get a circle mask like in the middle image, but with opencv you only get a rectangle crop? – Kaiwen Nov 02 '18 at 16:32
  • Yes sure, i mean. How to detect the circle mask in every image that we have. not rectangle crop. Do you have suggestion for this case ? – Tof1894 Nov 02 '18 at 19:24

0 Answers0