the how-do-I-remove-the-background problem
Posted: 2011-03-03T12:26:43-07:00
Hello,
I am trying to remove the background of plenty pictures. Unfortunately, the background of these pictures are neither solid nor always the same. Since I have to do the removal for more than 100 pictures, I would like to do that using a shell script.
First, some example pictures that resemble mine quite good:
http://www.bottleopener.com/images/P/op ... rew-01.jpg
http://3.bp.blogspot.com/_mByq_7EPwjg/S ... conome.jpg
http://upload.wikimedia.org/wikipedia/c ... stange.jpg
And here what I managed so far (sorry, I am a programmers beginner)
The percentage for the fuzz option I got by trial and error. Obviously, it is not the most suitable idea.
I did so far not really understand how that masking works. As far as I understand what I wrote in the code, I kind of subtract them from another. But this is not sufficient as it is now.
Does anyone have an advice?
Thank you very much in advance!!!
Hannes
I am trying to remove the background of plenty pictures. Unfortunately, the background of these pictures are neither solid nor always the same. Since I have to do the removal for more than 100 pictures, I would like to do that using a shell script.
First, some example pictures that resemble mine quite good:
http://www.bottleopener.com/images/P/op ... rew-01.jpg
http://3.bp.blogspot.com/_mByq_7EPwjg/S ... conome.jpg
http://upload.wikimedia.org/wikipedia/c ... stange.jpg
And here what I managed so far (sorry, I am a programmers beginner)
Code: Select all
#!/bin/bash
for k in *.jpg; do
convert $k $k.png
convert $k.png \( +clone -fx 'p{0,0}' \) -compose Difference -composite -modulate 100,0 +matte ${k}_diff.png
convert ${k}_diff.png -fill black -fuzz 03% -bordercolor black -border 1x1 -floodfill +0+0 black -shave 1x1 ${k}_diff03.png
convert ${k}_diff03.png $k.png -compose Difference -composite ${k}_diff03bg_removed.png
done
I did so far not really understand how that masking works. As far as I understand what I wrote in the code, I kind of subtract them from another. But this is not sufficient as it is now.
Does anyone have an advice?
Thank you very much in advance!!!
Hannes