Page 1 of 1

Color Filling

Posted: 2017-06-29T04:19:17-07:00
by jokokoe
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 !

Re: Color Filling

Posted: 2017-06-29T08:49:10-07:00
by fmw42
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.