how I could use kmeans in this image and obbtain the hair blonde color ?

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
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

how I could use kmeans in this image and obbtain the hair blonde color ?

Post by diegomage »

IM trying to convert elsa image but the blonde color in the image when I use kmeans

I use kmeans from this page
http://www.fmwconcepts.com/imagemagick/kmeans/index.php

Code: Select all

 ./kmeans elsa.png kdf_black2.png -n 15 -C LAB 

not works to get the color of hair and differentiate for skin pink color


INPUT IMAGE

Image

RESULT IMAGE
Image


please help me
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how I could use kmeans in this image and obbtain the hair blonde color ?

Post by fmw42 »

Try using seed colors in the script rather than just some number of colors. But I doubt that will work. You can also try -remap. See https://www.imagemagick.org/Usage/quantize/#remap
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

Re: how I could use kmeans in this image and obbtain the hair blonde color ?

Post by diegomage »

yes very thankyou I try but not get results .
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how I could use kmeans in this image and obbtain the hair blonde color ?

Post by fmw42 »

I do not know how to help. Your input image is rather poor.
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

Re: how I could use kmeans in this image and obbtain the hair blonde color ?

Post by diegomage »

I use kmeans for obtain the most common color and use a mask over each color and use a kmeans over each color mask of original image and combine all parts , repeating my code 5 times and works
this is my code

Code: Select all

 ./kmeans anna2.jpg kdf_black2.png -n 15  -colors 15  -c 0.3 -C sRGB -t flattened  >colorsf
convert anna2.jpg    -fuzz 100% -fill white -opaque black annafinal3.png
convert   annafinal3.png   -transparent white  annafinal3.png 

n=3

echo $n;n=$(($n + 1));p="p";vartt=$n$p;vartx=$(sed -n "$vartt" <colorsf);echo $vartx;echo $vartx > filevartx;x=$(grep  -Po '[^,]+$' filevartx);convert kdf_black2.png  -fill white +opaque "$x"  kdf_black3.png
convert kdf_black3.png  -fill black -opaque "$x"   kdf_black4.png;convert kdf_black4.png -negate kdf_black4x.png; convert anna2.jpg  -mask kdf_black4x.png         -fuzz 90% -fill white -opaque black  +mask kdf_black5.png
 ./kmeans  kdf_black5.png kdf_black2x.png -n 15  -colors 15  -c 0.3 -C sRGB -t flattened 
convert  kdf_black2x.png  -transparent white "annafinal$n.png"
z=$(($n - 1))
composite  "annafinal$z.png"  "annafinal$n.png"   "annafinal$n.png"
this is my result

Image

very thankyou
Post Reply