correct use of remap

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?".
Post Reply
spongemonkey
Posts: 20
Joined: 2012-10-08T13:42:11-07:00
Authentication code: 67789

correct use of remap

Post by spongemonkey »

I'm using using IM to do things related to printing so it's important that the hard work put into getting the image colours correct isn't undone by me messing everything up when I process them :P

I'm attempting to dither an image to a colour map (that will represent the possible ink combinations), but the result doesn't look right.

With this as my map (equally distributed colours in sRGB)
Image

dithering the night scape sample
Image

with the command

Code: Select all

convert.exe night_scape_orig.jpg -remap map.png night_scape_dithered.png
gives

Image

which is clearly too light.

I guess problem is something akin to this and I've been guessing at some solutions, but I'd like to know the definitive method?

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

Re: correct use of remap

Post by fmw42 »

My guess is that it is too light because your color map has too few gray colors. The darker one is too dark and the lighter one is too light. The algorithm chose the lighter one.

Also you might try adding +dither.
spongemonkey
Posts: 20
Joined: 2012-10-08T13:42:11-07:00
Authentication code: 67789

Re: correct use of remap

Post by spongemonkey »

Thanks for the reply.

I'm afraid +dither is not an option, the image has to be dithered using Floyd-Steinberg or similar. Using a darker colour map doesn't seem to help either, and besides IM should be able to do better than that with the above map. There is clearly not enough black on the wall to the right of the picture, it just isn't even close. Which is why I believe I'm not using the feature correctly and it's something to do with colour spaces? I'm a bit wary about being too reckless with the -colorspace and -set colorspace options (seeing as im just guessing at the moment), as the base image will have it's colours very carefully defined with ICC profiles.

I do appreciate your input and you taking the time to reply though.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: correct use of remap

Post by fmw42 »

I really do not think it is a colorspace issue. Both images are already sRGB. Perhaps it is a dithering issue.
spongemonkey
Posts: 20
Joined: 2012-10-08T13:42:11-07:00
Authentication code: 67789

Re: correct use of remap

Post by spongemonkey »

Does anyone have any more thoughts on this or want to come to the defense of the dithering results above?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: correct use of remap

Post by snibgo »

spongemonkey wrote:... which is clearly too light.
spongemonkey wrote:There is clearly not enough black on the wall to the right of the picture, it just isn't even close.
Why do you think this?

It looks about right to me, and the average pixel values in various sampling of the wall are the same for the _orig and _dithered versions.
snibgo's IM pages: im.snibgo.com
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: correct use of remap

Post by snibgo »

Of course, you might say, "I want more black pixels, even if that's not technically correct."

You could create a tone transformation curve that lowers the value of dark pixels while leaving brighter pixels unchanged. Apply this transformation before remapping:

Code: Select all

"%IMG%convert" ^
  night_scape_orig.jpg ^
  remap.ppm ^
  -clut ^
  -remap map.png ^
  rem.png
snibgo's IM pages: im.snibgo.com
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: correct use of remap

Post by anthony »

You probably should dither in linear colorspace. The map file is actually a linear-RGB colorspace map already.

Also you may like to increase teh dither tree-depth (-tree) Otherwise the dither function may not find the best color for the dither. :-(
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply