File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Number of colors in an Image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Number of colors in an Image " Watch "Number of colors in an Image " New topic
Author

Number of colors in an Image

John Eipe
Ranch Hand

Joined: May 23, 2008
Posts: 215
Hello,

I have a program that extracts the colors used in an image. The image is created by me using MSPaint (please take a look at the attached picture). I believe that the program should show atmost 7 unique colors. But i get many results. The code is given below:



Why does this happen?


[Thumbnail for circle.jpg]


www.cs-repository.info
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42941
    
  68
You'll probably find that the extra colors occur around the circles perimeters. Most drawing programs don't just paint a single line of black pixels, they add interpolated pixels to the left and right of the line in order to create a smooth appearance.

So there'll probably be lots of colors that are halfway between black and whatever color happens to occur on one side of the line. I'm sure high-end drawing apps have a way of preventing this; not sure about Paint, though.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Number of colors in an Image