should i use 2 color quantization for this?

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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

I answered your email but will repeat it here for the benifit of others.
Hmm tricky, sounds like what you want is something that maps any
primary color to that color, but anything else to black.

One solution I can think if is take a copy of the image and make specific colors
transparent, the use that to mask out all the other non-matching colors.

See the second example of
http://www.cit.gu.edu.au/~anthony/graph ... ransparent

For example

Code: Select all

   convert hd-tv.png  \( +clone -matte -fuzz %2 \
               -transparent blue \
               -transparent green \
               -transparent red \
               -fill black  -colorize 100% \) \
           -composite    primary_colors.png
This would return an image only showing colors close to just the specific colors specified,
and replace all other colors with black.


However now that I have a specific example (in a inexact JPEG format, avoid it if you can) I can see that the colors are not primary, but nicer off-primary colors. and the scoreboard has black and white text inside. Makes the problem harder.

Start as above, but only for the blue 'edge' color of the board. When you ahve extracted that outline, use it to fill the areas outside that area, and use the result to mask out everything but the insides. From that you can trim and extract the information contained.

I cant generate a solution however as the JPEG has corrupted the pixel information too much, specifically where the score board overlays the red banner.

Also some of the prople at the top middle-left have jackets with near identical colors, requiring even further work to isolate and remove solid 'blobs' pf that color, rather than just the scroeboard outline. It can be done, just not using a inexact and low quality JPEG image.
Last edited by anthony on 2007-01-28T21:35:38-07:00, edited 1 time in total.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

Using the bmp file you sent I cam up with this rough solution..

Code: Select all

convert foo1.bmp \( +clone -matte -fuzz 15% -transparent '#204db8' \
          -channel A -separate +channel \
          -blur 0x1 -threshold 10% -fill white -draw 'color 0,0 floodfill' \
          -blur 0x10 -threshold 70% -negate \) \
          -compose multiply -composite  scoreboard.jpg
Note it leaks into the logo as it has a wide gap in the border there but I managed to close the small gap in the border where the red banner was. allowing it to grab the appropriate bits.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply