How to cut a sub-part of an image using Emgu CV (or OpenCV)?

前端 未结 2 372
忘了有多久
忘了有多久 2021-01-18 08:55

I want to cut a sub-purt of an image (or crop it) using Emgu CV (or OpenCV) and calculate average color of that part; looking for changes.

Thanks

2条回答
  •  隐瞒了意图╮
    2021-01-18 09:00

    1. Set the ROI (Region of Interest) of the image you are working with this will mean any calculation is only done over this area.

      image.ROI = new Rectangle(x,Y,Width,Height);

    2. Calculate the Average of the ROI where "TYPE" is image dependant Bgr for colour Gray for Grayscale

    TYPE average = image.GetAverage(image);

    1. When youve finished reset your image ROI so you can see the whole image again.

    All the process does is loop through each pixel adds its value then divides by the total number of pixels. Saves you writing the code yourself.

    Thanks Chris

提交回复
热议问题