ordered dither checks and remapping possible?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
mattyrb
Posts: 19
Joined: 2018-10-03T08:08:10-07:00
Authentication code: 1152

ordered dither checks and remapping possible?

Post by mattyrb »

Hi,
I've been playing with dithering and remapping. I have images I want to reduce to a selected 16 colours from a colourmap of 512. I've got all that working nicely. However I'd like to use -ordered-dither checks rather than Riemersma or FloydSteinberg. Is this possible?

Best wishes,
Matt
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: ordered dither checks and remapping possible?

Post by snibgo »

Riemersma and FloydSteinberg are error-diffusion methods. "-ordered-dither" is a dither with no error diffusion. So I don't understand the question.
snibgo's IM pages: im.snibgo.com
mattyrb
Posts: 19
Joined: 2018-10-03T08:08:10-07:00
Authentication code: 1152

Re: ordered dither checks and remapping possible?

Post by mattyrb »

Okay I'm trying to remap an image to a colourmap of 512 then order dither it using checks to 16 colours?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: ordered dither checks and remapping possible?

Post by snibgo »

Sorry, I still don't understand. "-ordered-dither" makes each pixel either "on" or "off", so it can only make 8 colours, which are: black, white, red, green, blue, cyan, magenta and cyan.

It can't make 16 colours, or colours of your choosing. See http://www.imagemagick.org/Usage/quanti ... red-dither

Can you show an example of what you want?
snibgo's IM pages: im.snibgo.com
mattyrb
Posts: 19
Joined: 2018-10-03T08:08:10-07:00
Authentication code: 1152

Re: ordered dither checks and remapping possible?

Post by mattyrb »

I literally want to reduce my images to 16 colours but use a dither pattern that's consistent
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: ordered dither checks and remapping possible?

Post by snibgo »

Consistent in what sense?

If you want to reduce an image to 16 colours that you choose, then "-remap" will do that. But each pixel is assigned the closest of the 16 colours, either with error-diffusion dithering, or no with dithering. IM has no simple method for ordered-dithering with 16 chosen colours.
snibgo's IM pages: im.snibgo.com
mattyrb
Posts: 19
Joined: 2018-10-03T08:08:10-07:00
Authentication code: 1152

Re: ordered dither checks and remapping possible?

Post by mattyrb »

When I say consistent the dither pattern needs to be consistent obviously error-diffusion is too random :lol:
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ordered dither checks and remapping possible?

Post by fmw42 »

mattyrb wrote: 2018-10-03T14:59:03-07:00 When I say consistent the dither pattern needs to be consistent obviously error-diffusion is too random :lol:
I suspect he means the same unique pattern over the whole image, i.e. an ordered-dither
mattyrb
Posts: 19
Joined: 2018-10-03T08:08:10-07:00
Authentication code: 1152

Re: ordered dither checks and remapping possible?

Post by mattyrb »

fmw42 wrote: 2018-10-03T15:06:00-07:00
mattyrb wrote: 2018-10-03T14:59:03-07:00 When I say consistent the dither pattern needs to be consistent obviously error-diffusion is too random :lol:
I suspect he means the same unique pattern over the whole image, i.e. an ordered-dither
Yes! Sorry. I'm really new to image processing!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ordered dither checks and remapping possible?

Post by fmw42 »

User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ordered dither checks and remapping possible?

Post by fmw42 »

Also see the section https://imagemagick.org/Usage/quantize/#od_posterize for comparison of different methods.
mattyrb
Posts: 19
Joined: 2018-10-03T08:08:10-07:00
Authentication code: 1152

Re: ordered dither checks and remapping possible?

Post by mattyrb »

Order-dither is definitely what I'm after but I can't fathom how to restrict it to 16 colours? It looks like you can only restrict to RGB steps?

-ordered-dither checks,8,8,8 is what I have at present but I then have to run a quantize to reduce the colouring but that can't be right surely!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ordered dither checks and remapping possible?

Post by fmw42 »

I am not a dithering expert. But you could reduce the colors to 16 using +dither -colors 16, then do you ordered dither

Code: Select all

convert inputimage +dither -colors 16 -ordered-dither checks,8,8,8 outputimage
The +dither before -colors turns off dithering for reducing colors.

Alternately, you could create a 16 color colormap image

convert xc:color1 xc:color2 .... xc:color16 +append colormap.gif


and then do

Code: Select all

convert inputimage +dither -remap colormap.gif -ordered-dither checks,8,8,8 outputimage
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ordered dither checks and remapping possible?

Post by fmw42 »

Please always provide your IM version and platform/OS, since syntax may vary.
mattyrb
Posts: 19
Joined: 2018-10-03T08:08:10-07:00
Authentication code: 1152

Re: ordered dither checks and remapping possible?

Post by mattyrb »

Thanks I'll post back in the morning :)
Post Reply