It is currently Fri Apr 26, 2024 7:42 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: removing background
PostPosted: Sun Apr 19, 2015 8:05 am  (#1) 
Offline
New Member

Joined: Apr 19, 2015
Posts: 2
GIMP Version: 2.8.14
Operating System: Mac OS
OS Version: 10.10.2
GIMP Experience: New User



I need help removing the background off bulk pictures (2400 of them). I prefer to change it to black but also transparent is OK...
the thing is the background color is blue but with different shades in it going from dark blue to light blue very close to white, the objects i have containing all the other colors (minus black and blue...)

can someone help me do this automatically or just explain how i can do it fast?

ty for all the help!!!


Attachments:
File comment: thats an example picture
_WX81AB43RRP1_top__2015-04-150086.jpg
_WX81AB43RRP1_top__2015-04-150086.jpg [ 860.44 KiB | Viewed 4749 times ]
Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: removing background
PostPosted: Sun Apr 19, 2015 8:20 am  (#2) 
Offline
Global Moderator
User avatar

Joined: Apr 01, 2012
Posts: 7715
Location: On the other side of this screen
You could use the interactive foreground select 'GMIC filter under contour category' to cut it out.
If you have the patience you could also do it with the path tool then path to select, cut, paste as new image.

by the way, with your example do you want to leave the centre/pot plant stand, blue?

_________________


Top
 Post subject: Re: removing background
PostPosted: Sun Apr 19, 2015 8:44 am  (#3) 
Offline
GimpChat Member
User avatar

Joined: Jan 12, 2012
Posts: 178
Location: Mobile, AL USA
Are all of the subjects in the same location in all of the images? The reason I ask is that you'll need a garbage matte first to roughly isolate the subject, then a chroma key for the final mask. This is non-trivial, but possible if: a) the subject is consistently in the same location through all shots and b) no subject has colours close to your keying colour.

Also, you'll probably want something like imagemagick to actually do the bulk run.

_________________
patdavid.net
Image
PIXLS.US F/OSS Photography


Top
 Post subject: Re: removing background
PostPosted: Sun Apr 19, 2015 8:49 am  (#4) 
Offline
Global Moderator
User avatar

Joined: Apr 01, 2012
Posts: 7715
Location: On the other side of this screen
Image
Of course if you don't want a black background but transparent you dont need to add another layer.
EDIT: not sure what I did before (it did surprise me) I cannot do it again.
Anyway you will be better to follow Pat's advice.

_________________


Top
 Post subject: Re: removing background
PostPosted: Sun Apr 19, 2015 9:30 am  (#5) 
Offline
New Member

Joined: Apr 19, 2015
Posts: 2
in all the pics the objects are at the same spots but as you can see the plants may go out of the circle of the pot (even though the pot are located at the same spot)
and can you please explain a more- step by step for dummies please... I'm pretty goo at computers but a real newbie in photo editing\ GIMPing...

sallyanne- how time consuming was your try?


Top
 Post subject: Re: removing background
PostPosted: Sun Apr 19, 2015 10:54 am  (#6) 
Offline
GimpChat Member
User avatar

Joined: Jan 12, 2012
Posts: 178
Location: Mobile, AL USA
nadavdanz wrote:
in all the pics the objects are at the same spots but as you can see the plants may go out of the circle of the pot (even though the pot are located at the same spot)
and can you please explain a more- step by step for dummies please... I'm pretty goo at computers but a real newbie in photo editing\ GIMPing...

sallyanne- how time consuming was your try?


I am not at a computer at the moment (well, one with GIMP). But I will download and take a stab at it later. I'll probably just give you an imagemagick script (even if it only took 1 minute per image manually, you're looking at 40 hours of work across all your images).

_________________
patdavid.net
Image
PIXLS.US F/OSS Photography


Top
 Post subject: Re: removing background
PostPosted: Sun Apr 19, 2015 11:38 am  (#7) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2247
Location: Poland
Only 10 seconds


Attachments:
Extract.png
Extract.png [ 355.01 KiB | Viewed 4638 times ]

_________________
Image

Slava
Ukraini!
Top
 Post subject: Re: removing background
PostPosted: Sun Apr 19, 2015 12:35 pm  (#8) 
Offline
Administrator
User avatar

Joined: Aug 10, 2012
Posts: 13016
Location: Native to NYC living in Arizona, Gimp 2.8 & 2.10, Win 11 PC.
MareroQ wrote:
Only 10 seconds

:clap

_________________
Image
"A wise man learns more from a foolish question than a fool can learn from a wise answer"
Image


Top
 Post subject: Re: removing background
PostPosted: Sun Apr 19, 2015 12:45 pm  (#9) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2424
Wallace wrote:
MareroQ wrote:
Only 10 seconds

:clap


read the first post, only another 2399 remaining to process.

_________________
Image


Top
 Post subject: Re: removing background
PostPosted: Sun Apr 19, 2015 2:07 pm  (#10) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2247
Location: Poland
One possibility:
Open photos as layers (several?)
Use the GMIC (a single layer test)
Use Actions RWL http://gimpchat.com/viewtopic.php?f=9&t=11963


Attachments:
RVLV-GMIC.png
RVLV-GMIC.png [ 30.87 KiB | Viewed 4598 times ]

_________________
Image

Slava
Ukraini!
Top
 Post subject: Re: removing background
PostPosted: Sun Apr 19, 2015 6:47 pm  (#11) 
Offline
Administrator
User avatar

Joined: Aug 10, 2012
Posts: 13016
Location: Native to NYC living in Arizona, Gimp 2.8 & 2.10, Win 11 PC.
rich2005 wrote:
read the first post, only another 2399 remaining to process.


It's a start. :mrgreen:
The rest should take about 40 minutes or so to do. :hehe

_________________
Image
"A wise man learns more from a foolish question than a fool can learn from a wise answer"
Image


Top
 Post subject: Re: removing background
PostPosted: Sun Apr 19, 2015 9:11 pm  (#12) 
Offline
Script Coder
User avatar

Joined: Dec 27, 2014
Posts: 508
The GMIC "Extract objects" does leave slightly ragged edges, as this example shows:
Image

You might do slightly better using decompose to select the background by hue.
(As you noted in your first post, the background luminosity varies considerably from near-white to near-black, but the hue does not vary.)

To select and replace the background by hue:
- open image
- Colors>Components>Decompose (color model = HSL, decompose to layers = YES)
in the decomposed image:
- Image>Mode = RGB
- File>Open as layer(s) ..load the same original image, turn-off visibility (toggle the eye icon)
- select "hue" layer
- Select by Color Tool ..select the background (which should be all the same gray-level in the "hue" layer)
- Select>Shrink (1px)
- Select>Grow (2px)
- select the original image layer and turn on visibility
- Bucket Fill Tool ..fill whole selection with black (or whatever)
- crop image to suit and export as jpg, etc

Result:
Image

Note: both the above procedure and the GMIC Extract objects filter will leave some "funnies" and artefacts.
For example, there are white plastic plant-pot markers in the supplied image which reflect the background colour almost perfectly, so they get selected as "background" and replaced. Similarly with some parts of the rims of the pots which also reflect the background hue.

The above workflow could be scripted.
Question: do you actually want the images in pairs or separated?


Top
 Post subject: Re: removing background
PostPosted: Mon Apr 20, 2015 11:11 am  (#13) 
Offline
GimpChat Member
User avatar

Joined: Jan 12, 2012
Posts: 178
Location: Mobile, AL USA
I took a quick stab at it, and there will be some issues, but this may get you on a decent path... I am going to assume you've installed Imagemagick

First, I would do a garbage matte. That is, I would crop out all of the extraneous stuff in the image you don't care about. I would personally look at the image that has the biggest crop to get all of the plants in it, and use that. Open the image in GIMP, and do a rectangle select to get the dimensions:

Attachment:
GC-SCREEN1.png
GC-SCREEN1.png [ 395.61 KiB | Viewed 867 times ]


Look carefully at the area outlined in red, as this will give you your crop + offset parameters.

In your directory of images, create a temporary output directory, CROP. Then run this imagemagick command to crop all of your images:

mogrify -path CROP/ -crop 1211x741+407+378 +repage *.jpg


This will give you an entire sub-directory (CROP/) of pre-cropped images. Check those images to make sure that you don't need to adjust the crop parameters. If you do, you can just delete all the images in the sub-directory and re-run the command with new, adjusted parameters.

That step should at least be a little helpful no matter what final path you choose to key the images.

The next option worked semi-ok for me, but could probably have been better. I basically used this imagemagick command line to fuzz a color into transparency (if you don't need to retain filenames, you can use this command):

convert *.jpg -alpha set -channel RGBA -fill none -fuzz 20% -opaque "#HEXCODEOFBGCOLOR" %05d.png


Obviously, replace the HEXCODEOFBGCOLOR with the correct hex code of your background (I think I used #63bdf9 from your image).

Attachment:
00000.png
00000.png [ 584.94 KiB | Viewed 867 times ]


Adjust the fuzz parameter as needed to get a good result. It's a balancing act, but it's the fastest way to churn through 2400 images.

Another option I just thought about, if you're more comfortable approaching this as a chroma-keying exercise is to load up all of your images as as sequence in Blender, and use Blenders nodes to pull the key. There is already a keying and chroma-key node built into Blender to do this automatically, and you can simply have it output the results as png files as well.

Attachment:
blender-chroma.png
blender-chroma.png [ 726.46 KiB | Viewed 867 times ]

_________________
patdavid.net
Image
PIXLS.US F/OSS Photography


Top
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Removing flare

2

No new posts Attachment(s) removing px from the bottom of a image

4

No new posts Help removing mask from face

2

No new posts Removing text from a poster imported as an image

3

No new posts Attachment(s) 2 gif, 1 background, different speeds

10



* Login  



Powered by phpBB3 © phpBB Group