//load the input image ImageinputImage = new Image ("InputImage.jpg"); //set the dimensions of the histogram int[] histSize = new int[1] {256}; //set the range of pixel values to be considered for histogram float[] range = new float[2] {0, 256}; //calculate the histogram Mat histogram = new Mat(); CvInvoke.CalcHist(new Image [] {inputImage.Convert ()}, new int[] {0}, new Mat(), histogram, histSize, range);
//load the input image ImageIn the above example, the histogram of a rectangular region of interest in the input image is calculated using one dimension and 256 bins. The mask is used to specify the pixels in the input image that are to be considered for histogram calculation. Package Library used in above examples is "Emgu.CV".inputImage = new Image ("InputImage.jpg"); //define the region of interest Rectangle roi = new Rectangle(10, 10, 100, 100); //create the mask for the region of interest Mat mask = new Mat(inputImage.Size, DepthType.Cv8U, 1); mask.SetTo(new MCvScalar(0)); CvInvoke.Rectangle(mask, roi, new MCvScalar(255), -1); //set the dimensions of the histogram int[] histSize = new int[1] {256}; //set the range of pixel values to be considered for histogram float[] range = new float[2] {0, 256}; //calculate the histogram for the region of interest Mat histogram = new Mat(); CvInvoke.CalcHist(new Image [] {inputImage.Convert ()}, new int[] {0}, mask, histogram, histSize, range);