Color Filling

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
jokokoe
Posts: 1
Joined: 2017-06-29T01:31:28-07:00
Authentication code: 1151

Color Filling

Post by jokokoe » 2017-06-29T04:19:17-07:00

Hello everyone,

First of all, know that I'm relatively new using C++ language and it's my first time trying to code using magick++ library, so I'm a real beginner.
I have a series of picture like this one :

Image

where only the part inside the hexagon changes.

Now what I would like to do :

- Between the circle and the hexagon I would like to change the color from blue to something else ( green or red for example)
- I would like the blue color outside the circle to be white

Do you have any idea / advice how I could do that ? thank you !

User avatar
fmw42
Posts: 22091
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Color Filling

Post by fmw42 » 2017-06-29T08:49:10-07:00

Sorry, I do not use C++, but the command line that you want to emulate in C++ is:

Code: Select all

convert hexagon_circle.png -fill white -draw "color 5,5 floodfill" -fill red -draw "color 165,20 floodfill" -alpha off hexagon_red_circle_white.png
Image

I manually picked one pt outside the circle and one point between the circle and the hexagon. Then used color flood fill to replace the blue color in those two places with white and red.

See
http://www.imagemagick.org/Usage/draw/#color

If your blue colors in other images are not uniform, then you can add -fuzz XX% to allow colors that are similar to be replaced.

Post Reply