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
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
I think that newer versions of OpenCV (2.3+) have a different method of doing ROIs. Here's what the manual says:
Here is what I did in one instance:
You can use any of the subframes (
roi
andhead
in my example) to calculate the average of the region. There is anadjustROI
function to move the region of interest and a functionlocateROI
that may also be of use.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);
Calculate the Average of the ROI where "TYPE" is image dependant Bgr for colour Gray for Grayscale
TYPE average = image.GetAverage(image);
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