Post all Gimp scripts and script writing questions here
Post a reply

Selected areas to separate layers script request (SOLVED)

Thu Jul 04, 2013 12:22 pm

I am requesting a script to take selections of areas of an image and place those on separate layers.
I would like the script to either work with all objects on a transparent layer (such as text letters), or a user submitted selection.

Thanks. :)

Re: Selected areas to separate layers script request

Thu Jul 04, 2013 2:10 pm

Attached is one I wrote some time ago for separating sprite sheets and optionally turning them into an image hose. Doesn't do selections, just breaks up all the images separated by transparency.
Saving the gih files an option, else it just creates a new image with the separated images one per layer.

It shows up under Filters->Break Apart by Alpha...

Haven't looked at it for a while, but it should still work and might meet your needs.

-Rob A>

Re: Selected areas to separate layers script request

Thu Jul 04, 2013 3:06 pm

Just tried it Rob; cool stuff. I can see this useful for isolating Paintshop tubes to make GIH brushes since tubes tend to be be compact when they create them from some of the ones I've seen. Thanks for sharing. :)

Re: Selected areas to separate layers script request

Thu Jul 04, 2013 7:34 pm

I was just thinking about something like this. PaintShop Pro has a "promote selection to layer" function that would come in handy for my current project. This might help alot. :yes

Re: Selected areas to separate layers script request

Thu Jul 04, 2013 9:08 pm

For the selection, can this not just be done with:

1) Make selection
2) Copy (ctrl+C)
3) Edit->Paste as->New Layer (bind it to a key for ease of use...)

-Rob A>

Re: Selected areas to separate layers script request

Fri Jul 05, 2013 2:45 am

Thanks Rob. :)
Here is what i am trying to do.I have these huge images of shapes on alpha. So i want to break apart those shapes and save each one as a brush. This is exactly what i am looking for. ;) :bigthup

However it does show in menus, and it does begin but then nothing happens.
I have an image on a transparent layer filled with gears and want to remove each gear to a separate layer or directory.
Saving as image or brush would be awesome also.

My settings
Image

Re: Selected areas to separate layers script request

Fri Jul 05, 2013 3:22 am

Strange.
It works for a 4 letter text layer but not for a layer as i have shown. (gear image)
Image
Do i have to input EXACT number of items to isolate for it to work correctly?

Re: Selected areas to separate layers script request

Fri Jul 05, 2013 3:38 am

Okay using the exact number of shapes (57), made the script run. BUT
I got 7 layers of emptiness and 1 layer with all the gear shapes.

Image

Then running it again on just the layer with gear shapes to get a GIH, i got a gimp brush pipe. :) :bigthup
BUT there was nothing in it. Just white layers.

Re: Selected areas to separate layers script request

Fri Jul 05, 2013 10:12 am

:bump

Re: Selected areas to separate layers script request

Fri Jul 05, 2013 10:48 am

Rod wrote:Okay using the exact number of shapes (57), made the script run. BUT
I got 7 layers of emptiness and 1 layer with all the gear shapes.

[ Image ]

Then running it again on just the layer with gear shapes to get a GIH, i got a gimp brush pipe. :) :bigthup
BUT there was nothing in it. Just white layers.


You have very little separation between the gears Rod; might try to play with the size threshold setting but not sure. Have a link to this gear picture; like to toy with it myself. :)

Re: Selected areas to separate layers script request

Fri Jul 05, 2013 11:13 am

The issue is the gear image - There isn't enough separation of the gear images, especially with the drop shadow.

You could try using the levels tool on the alpha channel first to get rid of most of the drop shadow then try the script again.... Best I can suggest for now other than using a circular selection to select each and then manually cut/paste as new layer.

-Rob A>

Re: Selected areas to separate layers script request

Fri Jul 05, 2013 12:15 pm

I had a feeling that was the case Rob. Thanks a heap for the script too.
Lyle here is the image. :)

Image

Link to the kit itself. :)
http://rickulein.deviantart.com/art/Ste ... -371606404

Re: Selected areas to separate layers script request

Fri Jul 05, 2013 12:25 pm

Used color to alpha to create a mask and this is your image without drop shadow. Ran the script, but, the best I could come up with was 34 isolated objects (way too many extracts had multiple objects in them though). :)

Re: Selected areas to separate layers script request

Fri Jul 05, 2013 12:58 pm

Yep just not a good image for this script. Good script, bad image. :lol

Thanks anyways Lyle.
I extracted all of the images with their drop shadows yesterday (took forever). But i now have all of them as brushes.
At least now their is a way to extract all objects from a layer with transparency. :)
Very handy script to say the least. I am constantly extracting multiple renders from one image so this will be very useful for me at least.

Rob you rock! :)
Wish i would have known about this script a long time ago. :lol Would have saved a ton of work for sure.

Re: Selected areas to separate layers script request (SOLVED)

Fri Jul 05, 2013 1:12 pm

I agree with you Rod (RobA Rocks that is). I had more then one occasion to have needed such a way to extract individual objects too. Very much appreciate the Script-fu Rob. :)

Re: Selected areas to separate layers script request (SOLVED)

Fri Jul 05, 2013 3:39 pm

I've updated the script (attached) to include:
- A fuzziness parameter (The amount of feathering applied to the selection). Sliding this down from the default 100 (which is the maximum of the image w or height over 100) will get in closer to the objects but increases sensitivity to noise.
- A threshold parameter. This is how accurately the transparency will be matched, and if slid up from the default of 0 can be used to ignore semitransparent areas such as shadows. It will also have the effect of destroying antialiasing of transparency if pulled up too much.

Here is a zip of an xcf with all gears extracted to their own layers with this script (got 53 of them) and then the rest manually separated:
gears_manual.zip
(1.51 MiB) Downloaded 142 times

-Rob A>

Re: Selected areas to separate layers script request (SOLVED)

Fri Jul 05, 2013 4:12 pm

Nice Rob! Thanks a bunch. :)

Re: Selected areas to separate layers script request (SOLVED)

Fri Jul 05, 2013 4:22 pm

RobA wrote:I've updated the script (attached) to include:
- A fuzziness parameter (The amount of feathering applied to the selection). Sliding this down from the default 100 (which is the maximum of the image w or height over 100) will get in closer to the objects but increases sensitivity to noise.
- A threshold parameter. This is how accurately the transparency will be matched, and if slid up from the default of 0 can be used to ignore semitransparent areas such as shadows. It will also have the effect of destroying antialiasing of transparency if pulled up too much.

Here is a zip of an xcf with all gears extracted to their own layers with this script (got 53 of them) and then the rest manually separated:
gears_manual.zip

-Rob A>

Rob can you post a screenshot of your settings to get that many renders? I can't seem to get it to work very well for me.

Thanks again.

Re: Selected areas to separate layers script request (SOLVED)

Tue Jul 09, 2013 10:12 am

Rod wrote:Rob can you post a screenshot of your settings to get that many renders? I can't seem to get it to work very well for me.

Thanks again.


Can't recall, but this:
settings.jpg
settings.jpg (30.43 KiB) Viewed 2123 times

got all of them, with a little loss of some of the smaller teeth.

The Threshold slider reflect the amount of opacity is ignored - this can be used to eliminate the drop shadow. It reflects the 0-255 setting of the threshold slider when using select by colour.
The Fuzziness slider controls the size of smoothing applied to the selection. The default (100) was a value I chose that gets good isolation but keeps things fairly quick. Pulling it down increases the detail in the boundary when isolating objects (i.e smaller teeth).

-Rob A>

Re: Selected areas to separate layers script request (SOLVED)

Tue Jul 09, 2013 11:12 am

Thank you Rob for the example. That should help a ton. :)
Post a reply