Page 1 of 1

remap problem

Posted: 2013-01-31T07:26:12-07:00
by YayBjorn
I'm trying to remap images to 12 predefined colours to create an index of how much of each colour is represented in each image. However I'm not happy with the way my command is currently remapping colours. An example will show my problem:

I'm running the command like:

Code: Select all

convert input.jpg -colorspace RGB -dither none -remap colors.bmp output.bmp
input.jpg: Image
colors.bmp: http://static2.yaymicro.com/pub/examples/colors.bmp (small image, only 12 pixels)
output.bmp: http://static2.yaymicro.com/pub/examples/output.bmp

I'm actually running the command as:

Code: Select all

convert input.jpg -colorspace RGB -dither none -remap -format %c histogram:info:-
but I'm getting the exact same output with the output.bmp so it's easier to show what I'm not happy with.

I've tried different methods, but I end up getting what I would consider to be wrong colours for the remaps. The part of the image that is clearly orange, ends up being red. If I calculate the total distance of the RGB colours, it's closer to orange than to red. I'm also clearly not interested in the pink part, where I feel the image is grey or white. Doing dithering removes the pink parts and replaces them with grey and white, but the orange is still red.

How does ImageMagick do it's nearest neighbour calculations?
Any other way to use ImageMagick to do get the amount of predefined colours in an image?

Bjorn
_________________________________________________________________
Version: ImageMagick 6.8.0-7 2012-12-21 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenCL

Re: remap problem

Posted: 2013-01-31T09:27:20-07:00
by snibgo
What is "-colorspace RGB" doing in your commands? When I use that, I get your (bad) result. When I omit it, I get what I think is the correct result. You don't need to change the colorspace, and I think you shouldn't.

(As an aside, I would rather like to be able to specify an image and map in some other colorspace, such as CIELab. But IM, it seems, always does the calcs in RGB space.)