Skip to main content

Nearest neighbor color reduction

3 replies [Last post]
marc_boscher@ho...
Offline
Joined: 2006-02-14

Hello,

Is there a simple (and hopefully fast) way to do a simple nearest neighbor color reduction using a palette/lookup table? This algorithm would just pick the palette index that is closest to each pixel of the image. No dithering, no error diffusion...

Any ideas?
Thanks
Marc

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Brian Burkhalter

You should be able to use the "ColorQuantizer" operation which will also
calcaulte the palette.

Brian

On Thu, 12 May 2005 jai-interest@javadesktop.org wrote:

> Hello,
>
> Is there a simple (and hopefully fast) way to do a simple nearest neighbor color reduction using a palette/lookup table? This algorithm would just pick the palette index that is closest to each pixel of the image. No dithering, no error diffusion...
>
> Any ideas?
> Thanks
> Marc
> ---
> [Message sent by forum member 'marc_boscher@hotmail.com' (Marc)]
>
> http://www.javadesktop.org/forums/thread.jspa?messageID=79722&#79722
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>

----------------
Brian Burkhalter
Advanced Development, Graphics and Media
Software Chief Technology Office
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Marc Boscher

But I want to be able to specify the palette to use, which ColorQuantizer
doesn't let me do...

I'm trying ErrorDiffusion with a 1x1 kernel of 0 (new float[]{0}). It seems
to work at first sight, but it seems overkill.

Thanks
Marc

-----Original Message-----
From: Brian Burkhalter [mailto:Brian.Burkhalter@Sun.COM]
Sent: May 12, 2005 3:11 PM
To: interest@jai.dev.java.net
Subject: Re: [JAI] Nearest neighbor color reduction

You should be able to use the "ColorQuantizer" operation which will also
calcaulte the palette.

Brian

On Thu, 12 May 2005 jai-interest@javadesktop.org wrote:

> Hello,
>
> Is there a simple (and hopefully fast) way to do a simple nearest neighbor
color reduction using a palette/lookup table? This algorithm would just pick
the palette index that is closest to each pixel of the image. No dithering,
no error diffusion...
>
> Any ideas?
> Thanks
> Marc
> ---
> [Message sent by forum member 'marc_boscher@hotmail.com' (Marc)]
>
> http://www.javadesktop.org/forums/thread.jspa?messageID=79722&#79722
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>

----------------
Brian Burkhalter
Advanced Development, Graphics and Media
Software Chief Technology Office
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Brian Burkhalter

Marc,

On Thu, 12 May 2005, Marc Boscher wrote:

> But I want to be able to specify the palette to use, which ColorQuantizer
> doesn't let me do...

I was wondering about that.

> I'm trying ErrorDiffusion with a 1x1 kernel of 0 (new float[]{0}). It seems
> to work at first sight, but it seems overkill.

That was to be my next suggestion. Please let us know whether it works for
sure.

Also, you might want to file an Enhancement issue in the jai-core project to
add such an operation. I think the native layer already includes this
operation but a wrapper for it as well as a Java-only implementation would
have to be created.

Brian

----------------
Brian Burkhalter
Advanced Development, Graphics and Media
Software Chief Technology Office
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net