easier way to convert image into selection
This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.
This is a read-only list on gimpusers.com so this discussion thread is read-only, too.
easier way to convert image into selection | Alexander Rabtchevich | 14 Sep 16:48 |
easier way to convert image into selection | David Gowers | 14 Sep 17:10 |
easier way to convert image into selection | William Skaggs | 14 Sep 18:05 |
easier way to convert image into selection | David Gowers | 15 Sep 02:09 |
easier way to convert image into selection | David Gowers | 15 Sep 02:36 |
easier way to convert image into selection | David Gowers | 15 Sep 02:51 |
easier way to convert image into selection | David Gowers | 15 Sep 03:59 |
easier way to convert image into selection | Sven Neumann | 17 Sep 14:59 |
easier way to convert image into selection | David Gowers | 18 Sep 01:03 |
easier way to convert image into selection | Sven Neumann | 18 Sep 09:38 |
easier way to convert image into selection | saulgoode | 18 Sep 03:46 |
easier way to convert image into selection | saulgoode | 18 Sep 03:50 |
easier way to convert image into selection
Some plug-ins (edge detection for example) provide images as a result. If their result is required as a selection, I new only one way to make it: create layer mask, copy the image into the mask and convert the mask into selection. Is there a shorter way to do it?
More common question: maybe it worth improving such plug-ins with an option "Create selection"?
easier way to convert image into selection
When I am doing this by hand, I do the following:
1. Copy the image/layer (as in Edit->Copy)
2. Enter QMask mode
3. Paste the copied data into the QMask
4. Anchor the floating layer created by pasting.
5. Exit QMask
If the edge-detection algorithym you're using only cares about overall
intensity (greylevel) rather than color (RGB), you could even perform the
edge-detection while you were in QMask mode.
So, maybe this is what you want:
1. Copy the original data
2. Enter QMask mode
3. Paste and Anchor.
4. Edge-detect.
5. Exit QMask mode.
If the edge-detection algorithym does work properly on the grey version of
the image, this method will be the easiest + quickest.
Doing it automatically as part of a plugin is somewhat different: I Named Copy the image/layer, Named Paste it into a new channel, Load the new channel using gimp-selection-load PDB function, and finally delete the buffer that was created by Named Copy.
Take your pick.
On 9/15/06, Alexander Rabtchevich wrote:
Some plug-ins (edge detection for example) provide images as a result. If their result is required as a selection, I new only one way to make it: create layer mask, copy the image into the mask and convert the mask into selection. Is there a shorter way to do it?
More common question: maybe it worth improving such plug-ins with an option "Create selection"?
--
With respect
Alexander Rabtchevich
easier way to convert image into selection
From: Alexander Rabtchevich
Some plug-ins (edge detection for example) provide images as a result. If their result is required as a selection, I new only one way to make it: create layer mask, copy the image into the mask and convert the mask into selection. Is there a shorter way to do it?
More common question: maybe it worth improving such plug-ins with an option "Create selection"?
I don't think so, but it might be nice to have a "layer to selection" filter that would create a selection from the gray values of the active layer.
-- Bill
______________ ______________ ______________ ______________
Sent via the CNPRC Email system at primate.ucdavis.edu
easier way to convert image into selection
On 9/15/06, William Skaggs wrote:
From: Alexander Rabtchevich
Some plug-ins (edge detection for example) provide images as a result. If their result is required as a selection, I new only one way to make it: create layer mask, copy the image into the mask and convert the mask into selection. Is there a shorter way to do it?
More common question: maybe it worth improving such plug-ins with an option "Create selection"?
I don't think so, but it might be nice to have a "layer to selection" filter that would create a selection from the gray values of the active layer.
-- Bill
Working on it.
It's much easier to code 'image to selection':
c = pdb.gimp_channel_new_from_component(image, GRAY_CHANNEL, 'TEMP
IMAGE2SELECTION')
image.add_channel(c)
pdb.gimp_selection_load(c)
image.remove_channel(c)
gimp.delete(c)
'layer to selection' is:
pdb.gimp_selection_none(image)
buf = pdb.gimp_edit_named_copy(drawable, bufname)
c = pdb.gimp_channel_new(image, image.width, image.height,
bufname, 50.0, (0,0,0))
image.add_channel(c)
fsel = pdb.gimp_edit_named_paste(c, buf, False)
pdb.gimp_floating_sel_anchor(fsel)
pdb.gimp_selection_load(c)
image.remove_channel(c)
gimp.delete(c)
easier way to convert image into selection
On 9/15/06, David Gowers wrote:
On 9/15/06, William Skaggs wrote:
From: Alexander Rabtchevich
Some plug-ins (edge detection for example) provide images as a result. If their result is required as a selection, I new only one way to make it: create layer mask, copy the image into the mask and convert the
mask
into selection. Is there a shorter way to do it?
More common question: maybe it worth improving such plug-ins with an option "Create selection"?
I don't think so, but it might be nice to have a "layer to selection" filter that would create a selection from the gray values of the active layer.
-- Bill
Someone broke the undo grouping in CVS gimp. The attached plugin provides 'layer to selection' and 'image to selection' functionality. 'layer to selection' has one image.undo_group_start() but two image.undo_group_end()s. This is because of the mentioned breakage: someone has made it so that I need to do two undo_group_end()s for each undo_group_start(). All my other plugins depending on undo groups broke too.
easier way to convert image into selection
On 9/15/06, David Gowers wrote:
Someone broke the undo grouping in CVS gimp. The attached plugin provides 'layer to selection' and 'image to selection' functionality. 'layer to selection' has one image.undo_group_start() but two image.undo_group_end()s. This is because of the mentioned breakage: someone has made it so that I need to do two undo_group_end()s for each undo_group_start(). All my other plugins depending on undo groups broke too.
Actually, some of my plugins still work. The ones that use floating
selection manipulation do not.
Plugins that do not work:
* this one
* QuickAA (which floats the selection and antialiases its edges)
Ones that use undo grouping and do work include * 'Apply layer' : http://bugzilla.gnome.org/show_bug.cgi?id=355730 * 'Maximum layer alpha to sel':
def plug_in_maximize_selection(self, run_mode, image, drawable):
#maximize the selection --
#used to determine the effected area.
#maximizing any alpha-thing (layer alpha or layer mask)
#can be used similarly.
#
#2 is used rather than 1, because the output of potrace includes
spurious/doubtful 1's
pdb.gimp_threshold(image.selection, 2,255)
def plug_in_maxlayeralpha_to_selection(self, run_mode, image, drawable):
image.undo_group_start()
if drawable.is_layer_mask:
drawable = filter(lambda v: v.mask == drawable, image.layers)[0]
pdb.gimp_selection_layer_alpha(drawable)
if drawable.mask:
pdb.gimp_channel_combine_masks(image.selection, drawable.mask,
CHANNEL_OP_INTERSECT, 0,
0)
pdb.gimp_threshold(image.selection, 2,255)
image.undo_group_end()
So I'm fairly sure it originates in the floating selection code, this bug.
easier way to convert image into selection
On 9/15/06, David Gowers wrote:
So I'm fairly sure it originates in the floating selection code, this bug.
It looks like that problem was a compilation glitch; 'make clean;make' fixed it. ^_^
easier way to convert image into selection
Hi,
On Fri, 2006-09-15 at 09:39 +0930, David Gowers wrote:
It's much easier to code 'image to selection':
c = pdb.gimp_channel_new_from_component(image, GRAY_CHANNEL, 'TEMP IMAGE2SELECTION')
This works for grayscale images only. An RGB image doesn't have a grayscale component. For grayscale images there is also no point in writing such a script because you can already choose "Channel to Selection" from the channel's right-click menu.
Sven
easier way to convert image into selection
On 9/17/06, Sven Neumann wrote:
Hi,
On Fri, 2006-09-15 at 09:39 +0930, David Gowers wrote:
It's much easier to code 'image to selection':
c = pdb.gimp_channel_new_from_component(image, GRAY_CHANNEL, 'TEMP IMAGE2SELECTION')
This works for grayscale images only. An RGB image doesn't have a grayscale component. For grayscale images there is also no point in writing such a script because you can already choose "Channel to Selection" from the channel's right-click menu.
I tested it for RGB images and it appears to work correctly. Perhaps it just uses the 1st channel (R) though.
easier way to convert image into selection
From: Alexander Rabtchevich
Some plug-ins (edge detection for example) provide images as a result. If their result is required as a selection, I new only one way to make it: create layer mask, copy the image into the mask and convert the mask into selection. Is there a shorter way to do it?
I wrote a Script-fu which performs something similar: it converts the image contents of the current selection into the selection. The selection created only includes the pre-existing selection, so perform a "Select None" or "Select All" before executing the command if you wish the entire layer to be converted into a selection. (Note: the command also works with layermasks and channels.)
The function appears on the "Select" menu as "From Drawable".
easier way to convert image into selection
It would probably help if I provided a link to the script. :-)
http://flashingtwelve.brickfilms.com/GIMP/Scripts/layer-select.scm
Also, the file includes another function (which selects the boundaries of the active layer).
easier way to convert image into selection
Hi,
On Mon, 2006-09-18 at 08:33 +0930, David Gowers wrote:
I tested it for RGB images and it appears to work correctly.
Perhaps it just uses the 1st channel (R) though.
That's what it does. Perhaps the procedure should warn instead.
Sven