Image Histogram Java Tool

I have recently developped a simple Java GUI-based tool which plots a histogram of a JPG image. The tool manually implements the code for computing and plotting the histograms. It also uses a suple histogram smoothing. The following types of histograms algorithms are computed:

  • Luminosity – the histogram for the luminosity of the pixels is computed.
  • Grayscale 1 – a red-blue-green color pixel is converted into a representative gray pixel based on one popular forumula and the grayscale histogram is computed.
  • Grayscale 2 – a red-blue-green color pixel is converted into a representative gray pixel based on second popular forumula and the grayscale histogram is computed.
  • Red – the histogram for the red color is computed.
  • Green – the histogram for the green color is computed.
  • Blue – the histogram for the blue color is computed.

You can download the source code from ImageHistogram.zip Eclipse Project and a JAR package from ImageHistogram.jar.

Tags: , ,

{ 16 comments to read ... please submit one more! }

  1. Interesting, thanks for sharing. I have also checked the source code, and it is a pleasure to read it. The project is interesting and useful by itself, but I am curious what do you need this for? Histograms are cool, but I'm still looking for how to put them to good use :) Some ideas come to mind for extending the app to calculate histograms of images provided by url, for example from flickr. Maybe I'll try to do that.

  2. Hi Hristo, I am working on a project related to image processing. To better understand the basics I wanted to implement operations such as histogram, overlay, etc. from the scratch. These programs alone would not serve nothing much useful for the end users, but they would be useful for developers who are interested in implementing such feature. In other words starting point or part of a big program. The code is very simple and tidy so it would be straightforward for somebody to see and understand how image histograms are extracted. Поздрави!

  3. Wow, that’s so very coool program. This program is free open source? Can I use this code for commercial use (or some parts)?

  4. Yes, go ahead use for whatever you want – commercial, home use.

  5. Sir, I have some questions.
    How can I determine the right threshold value from an image?
    I want to have the easy way.
    I have read some tutorials but all of them were difficult to implement.
     

  6. What threshold value do you mean?

  7. I want to know that can i get the source code of ImageHistogram.jar. it is a package so if i want to make my own package want can I do ?

    can you please help me with that?

    Cheers

    Quetypai

  8. Quetypai, you can get the source code by downloading it — read the last sentence from the pist ".. You can download the source code from ImageHistogram.zip Eclipse Project". 

    To make your package take the source code and include it in yours.

    Ferad

  9. Hello Feradz,

    Thank you very much and this code has been very helpfull to me,

    have gooday mate,

    Cheers,

    Quetypai

     

  10. Hello Feradz,

    One more thing to ask  I want to take image from a file which is in database and display all thing on web page so should I have to include some more code for that or write filename of database

    and should I have to write my filename instead of filename  in all the codes

    for example  public String getFileName() {
          return _fileName;

    OR
     public String getFileName() {
          return _Image;
     

    please do reply ASAP

    Thank you very much and this code has been very helpfull to me,

    have gooday mate,

    Cheers,

    Quetypai

     

  11. Hi Quetypai,

    I am afraid I did not understand your question. What is in database, the image itself or the name of the file? Certainly you need to implement code to access/query the database for the image or the file name. You can look in internet about examples how to access DB in java.

    Here are several examples:

    Connect to MS SQL server

    http://stackoverflow.com/questions/2451892/how-do-i-connect-to-a-sql-server-2008-database-in-java-with-jdbc

    Connect to MySQL

    http://www.javaworkspace.com/connectdatabase/connectMysql.do

  12. Hi Feradz,

    I was asking that if i want to include other file that containss lots of image approx 300 images,

    this file is named as Image

    and i want to fatch that file in  java coding

    so what i have to do, where do i have to include that file name in histogram java code which you have made?

  13. Hi Quetypai,

    So what I understand, you have some special file (big file) which contains several images embedded inside it and you want to load each image data from that file iteratively and compute its histogram. Is this correct? Or you have a directory with multiple images and want to load each image and compute its histogram?

    The method in the code which is used to load a single JPEG file inside the code is called: Histogram.getHistorgram(fileName). Respectively this method loads the image and calls other private methods parseGrayHistogram and parseHistogramForColors which compute the histograms of the loaded binary image.

    Hope this resolves your problems.

    Ferad

     

  14. Hi again Feradz,

    yes you are right that I have a special file,

    but is there any other codeings were we can calculate histogram and then pass a query so that when user input image id or name,

    the output display would be all the similar images reated to that selected image  based acording to coveriance, color and texture?

    sorry for giving you pain, but its like very urgent thing to me

    please do reply ASAP

    Thank you again,

    Quetypai

  15. Hi Quetypai, In your case you need a custom way to parse that big file for the individual images inside. How you do it would depend on many things, format of the images, compression, format of the file etc. 

  16. I think I am the latext to benefit from this blog. Nice one there. Any tip to determine whether and eye is open or closed in an image in java?

{ 0 Pingbacks/Trackbacks }

Leave a Reply

Your email address will not be published. Required fields are marked *