remap problem

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
YayBjorn
Posts: 4
Joined: 2010-10-11T05:57:00-07:00
Authentication code: 8675308

remap problem

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: remap problem

Post 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.)
snibgo's IM pages: im.snibgo.com
Post Reply