Page 1 of 1

Remove colors of an image one by one

Posted: 2019-01-11T04:51:48-07:00
by BigNoub
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)

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
This is temp_0.jpg

Image

It works well for the first step, temp_1.jpg:

Image

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]

Re: Remove colors of an image one by one

Posted: 2019-01-11T06:08:31-07:00
by snibgo
You save each result to JPG. But that is a lossy format, so some of your replaced colours won't be what you expect. I suggest you use a lossless format such as PNG (which will be slower) or tiff (not with jpeg compression) or miff.