Re: Frequency of colors
Re: Frequency of colors
- Subject: Re: Frequency of colors
- From: David Remahl <email@hidden>
- Date: Tue, 25 Mar 2003 20:54:29 +0100
I suppose the reason why you want to find this, is that you want to
approximate the image in 4 bit?
It is a bit difficult to give you a direct advice, without knowing what
you are going to use the information for. Images can contain a lot of
colors, and it is difficult to know where to draw the line between one
color and the next. To see a histogram of the colors used in an image,
you can use Photoshop.
There are many different algorithms to quantize images. In MacBoot,
which downsamples images to 8 bit, and selects the color table
accordingly, I use the "NeuQuant" algorithm presented on this page:
<
http://members.ozemail.com.au/~dekker/NEUQUANT.HTML>. It produces
extremely good results, and is actually reasonably fast.
For some sample code, you can download the source to MacBoot from
<
http://ittpoi.com/macboot.html>. In brief, you must first retreive the
image data as a bitmap image representation from the image in the image
view. You then apply the algorithm, which is in C to the image data,
and get a color table. You can then use the color table to calculate
the closest match for each source pixel, to get a downsampled image.
Note that NeuQuant doesn't work too well for just 16 colors, without
modification. Also note that if the source image contains many simillar
colours, the color table will also have many colours that are the same.
/ Hope this helps, David Remahl
Hello,
does somebody know how to find the 16 most used colors in a
NSImageView with Cocoa & Obj-C?
Thanks,
Luca.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.