Histogram Equalization not working

asked Jun 30 '17

arqam gravatar image

updated Oct 23 '0

I am trying histogram equalization but its giving me the same image as the input.

It seems like histogram equalization is having no impact. Can anyone tell where am I going wrong?

private static Mat adjustBrightnessContrast(Mat srcImage){
        Mat filterImage = srcImage.clone();
        Imgproc.cvtColor(srcImage,filterImage,Imgproc.COLOR_BGR2YCrCb);
        java.util.List<Mat> filterImageList = new ArrayList<Mat>(3);
        Core.split(filterImage,filterImageList);
        Mat luminance = filterImageList.get(0);
        Imgproc.equalizeHist(luminance,luminance);
        filterImageList.set(0,luminance);
        Core.merge(filterImageList,srcImage);
        Imgproc.cvtColor(filterImage,srcImage, Imgproc.COLOR_YCrCb2BGR);
        return srcImage;
    }

What I have done is converted the image from BGA to YCrCb format, and then performed histogram equalization on the first channel that is 0, after converting the image to list format. Then the Mat format I got after implement hist. eq. I replace the list with it. And finally merge the list with the sourceImage.

But I am getting the same output as input.

I am trying on this image as ::

image description

PS : I think I am doing some mistake in color part of the conversion as GRAYSCALED images worked properly.

Preview: (hide)