Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Histogram Equalization not working

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 shown in wikipedia(the output can be checked also in wiki page) ::

image description

Histogram Equalization not working

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 shown in wikipedia(the output can be checked also in wiki page) ::

image description

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

Histogram Equalization not working

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 shown in wikipedia(the output can be checked also in wiki page) ::

image descriptionimage description

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

Histogram Equalization not working

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.