Remove colors of an image one by one
Posted: 2019-01-11T04:51:48-07:00
I'm trying to remove the colors of an image one by one (greys and black included in what I mean by colors), as if I was making layers invisible one by one in Photoshop.
I tried to use Fred's scripts dominantcolor and replacecolor in a loop:
(original image temp_0.jpg)
This is temp_0.jpg
It works well for the first step, temp_1.jpg:
but then I'm unable to remove the greys and blacks, all images look similar to temp_1.jpg (with a few more white pixels). I'm not sure if it's because dominantcolor can not distinguish between the greys or because replacecolor can not find the specified grey colors, but I'm stuck there.
[Edit: if you think I should specify more the steps I need, let's say I want to delete all colors, then delete all grays, then delete all pure black. That would already be nice. Deleting the grays in 2 steps would be nicer but not absolutely necessary]
I tried to use Fred's scripts dominantcolor and replacecolor in a loop:
(original image temp_0.jpg)
Code: Select all
for i in 0 1 2 3 4 5; do
main_color=`./dominantcolor.sh -m 1 temp_"$i".jpg`
let "j = i + 1"
./replacecolor.sh -i "$main_color" -o white temp_"$i".jpg temp_"$j".jpg
done
It works well for the first step, temp_1.jpg:
but then I'm unable to remove the greys and blacks, all images look similar to temp_1.jpg (with a few more white pixels). I'm not sure if it's because dominantcolor can not distinguish between the greys or because replacecolor can not find the specified grey colors, but I'm stuck there.
[Edit: if you think I should specify more the steps I need, let's say I want to delete all colors, then delete all grays, then delete all pure black. That would already be nice. Deleting the grays in 2 steps would be nicer but not absolutely necessary]