Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Histogram Equalization - wrong format after cvCreateImage? #25

Closed
GoogleCodeExporter opened this issue Oct 9, 2015 · 9 comments
Closed

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
Histogram Equalization:
public BufferedImage Equalize(BufferedImage img)
{
    IplImage img = IplImage.createFrom(img);
    IplImage out = cvCreateImage(cvSize(img.width, img.height), IPL_DEPTH_8U, 1);       

    // Perform histogram equalization
    cvEqualizeHist( out, out );

        BufferedImage eqimg = out.getBufferedImage();
    out.release();

        return eqimg;    
}

What is the expected output? What do you see instead?
The returned equalized image "eqimg" is not displayable on my GUI. The "img" I 
pass into the function however works fine, but not the returned "eqimg".

What version of the product are you using? On what operating system?
Lastest javacv version, Windows 7.

Please provide any additional information below.
Even if I perform a simple grayscale conversion, it has the same problem:
public BufferedImage GrayConversion(BufferedImage img)
{
    IplImage img = IplImage.createFrom(img);
    IplImage out = cvCreateImage(cvSize(img.width, img.height), IPL_DEPTH_8U, 1);       

    BufferedImage grayimg = out.getBufferedImage();
    out.release();

        return grayimg;   
}

Hence, I might be doing something wrong in the following line?:
IplImage out = cvCreateImage(cvSize(img.width, img.height), IPL_DEPTH_8U, 1);

Original issue reported on code.google.com by pendieee...@hotmail.com on 4 Oct 2010 at 11:19

@GoogleCodeExporter
Copy link
Author

Did you try cvEqualizeHist( img, out ) instead?

Original comment by samuel.a...@gmail.com on 4 Oct 2010 at 11:32

@GoogleCodeExporter
Copy link
Author

Yes, but even wors; it compiles, but it crashes on Runtime..
How about the Grayscale conversion problem?

Original comment by pendieee...@hotmail.com on 4 Oct 2010 at 12:04

@GoogleCodeExporter
Copy link
Author

I made some changes to that recently to fix issue #24. Can you try with this 
test package instead and see what happens? thanks
    http://www.ok.ctrl.titech.ac.jp/~saudet/javacv.jar

Original comment by samuel.a...@gmail.com on 4 Oct 2010 at 1:12

@GoogleCodeExporter
Copy link
Author

Unfortunately it's still the same..

Original comment by pendieee...@hotmail.com on 4 Oct 2010 at 2:36

@GoogleCodeExporter
Copy link
Author

If you are trying to convert a color image to a gray image, you should used the 
cvCvtColor() function, as exemplified in the README.txt file:
            // Let's try to detect some faces! but we need a grayscale image...
            cvCvtColor(grabbedImage, grayImage, CV_BGR2GRAY);
Does the cvCvtColor() function work or not?

Original comment by samuel.a...@gmail.com on 5 Oct 2010 at 11:43

@GoogleCodeExporter
Copy link
Author

That works perfect for grayscale!

However, we still have the problem with histogram equalization. In particular, 
I have found that the problem might be with the cvCreateImage part: I created a 
function to test just cvCreateImage, and in fact it does not work:
public BufferedImage testcvCreateImage(BufferedImage animg)
{
    IplImage img = IplImage.createFrom(animg);

        IplImage testimg = cvCreateImage(cvSize(img.width, img.height), IPL_DEPTH_8U, 1);       

        BufferedImage testBufferedimg = testimg.getBufferedImage();

        return testBufferedimg; //NOT DISPLAYABLE       
}

This might be causing the histogram equalization to fail? Or it may need to be 
treated as a new, separate issue?

Original comment by pendieee...@hotmail.com on 5 Oct 2010 at 12:35

@GoogleCodeExporter
Copy link
Author

What do you mean "NOT DISPLAYABLE"? What happens? testimg is an initialized 
image, it's not going to contain anything interesting..

Original comment by samuel.a...@gmail.com on 5 Oct 2010 at 1:33

@GoogleCodeExporter
Copy link
Author

True, I was doing it the wrong way. For future readers looking for a sample 
code in javacv for histogram equalization, this sample function code works just 
fine (thanks Samuel, you can now close this issue):
public BufferedImage Equalize(BufferedImage bufferedimg)
    {
        IplImage iploriginal = IplImage.createFrom(bufferedimg);

        IplImage srcimg = IplImage.create(iploriginal.width, iploriginal.height, IPL_DEPTH_8U, 1);
        IplImage destimg = IplImage.create(iploriginal.width, iploriginal.height, IPL_DEPTH_8U, 1);

        cvCvtColor(iploriginal, srcimg, CV_BGR2GRAY);

    cvEqualizeHist( srcimg, destimg );

        BufferedImage eqimg = destimg.getBufferedImage();

        return eqimg;
    }

Original comment by pendieee...@hotmail.com on 5 Oct 2010 at 2:29

@GoogleCodeExporter
Copy link
Author

Good!

Original comment by samuel.a...@gmail.com on 8 Oct 2010 at 3:01

  • Changed state: Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant