Image processing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • popprem
    New Member
    • Nov 2008
    • 19

    Image processing

    Hi,

    I have a requirement to calculate the blue colored area in an JPG image. Can anyone suggest me a way to do this please?

    References for any libraries or APIs are highly appreciated.

    Thanks in advance.

    Regards,
    Prasath.
  • chaarmann
    Recognized Expert Contributor
    • Nov 2007
    • 785

    #2
    Just convert the image into a RGB-bitmap where a pixel is 3 bytes (red, green, blue). Then loop through the bytes of the bitmap and count the ones with a blue color. For example "0x0000FF" is a 100% blue dot. But maybe you also want slightly lighter or darker blue dots to be recognized, because the source was jpg, so you should define a derivation value accordingly. For example if you define value=3, then "0x0300FC" would also count as blue dot.

    The java Image-IO is included since JDK1.4. Just read the normal API for it. (for example javax.imageio.I mageIO.Buffered Image)

    Comment

    • popprem
      New Member
      • Nov 2008
      • 19

      #3
      Hi Chaarmann,

      Thanks a lot for the reply. Yeah, i too got the point about
      iterating pixels. I get jpg images as input for this
      program. So can i do the image conversion from jpg to bytes
      in the code level?

      Please provide me a sample.

      Thanks.

      Comment

      • chaarmann
        Recognized Expert Contributor
        • Nov 2007
        • 785

        #4
        Have you looked up the API I mentioned?
        I have no time to do that right now, but there should be a single command to load an image of type jpg from disk into memory. And another command to directly access the image buffer. I think you need to convert the image to bmp before accessing the image buffer, so that you have rgb-values inside the buffer or you don't need to convert and can get the pixel direcly with "int rgb = bufferedImage.g etRGB(x, y)", but I can't remember exactly. You can find a lot of code examples if you google for "java Image-IO" or some of its classes.

        Comment

        • popprem
          New Member
          • Nov 2008
          • 19

          #5
          Thanks for your reply Chaarmann. I got the hight and width
          of the image, iterating through them and checking for blue
          color pixels using "int rgb = bufferedImage.g etRGB(x, y)"
          and checking rgb for 0x0000FF.

          Thanks a lot.

          Comment

          Working...