• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Number of colors in an Image

 
John Eipe
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
circle.jpg
[Thumbnail for circle.jpg]
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic