On Mon, Sep 27, 2010 at 3:45 AM, Ofnuts <ofnuts@xxxxxxxxxxx> wrote: > On 24/09/2010 17:05, Joao S. O. Bueno wrote: >> >> On Fri, Sep 24, 2010 at 11:19 AM, Ofnuts<ofnuts@xxxxxxxxxxx> Âwrote: >>> Â Hi, >>> >>> My code needs to do a one-pixel-wide selection, at distance "x" from the >>> current selection. ÂThis looks a lot like a border selection except that >>> the border selection creates at best a two-pixel wide ribbon and I only >>> want one (but if I'm wrong, please tell me how to :-) >>> >>> So far my code goes like this: >>> >>> # Selects pixels that are between x and x+1 pixels from >>> # the original selection. Bumping the selection by one >>> # each time doesn't work, a small circle degenerates into >>> # a square with rounded corners instead of a big circle. >>> Â Â Âdef select_ribbon(self,image,selection,dist): >>> Â Â Â Â Âpdb.gimp_selection_load(selection) >>> Â Â Â Â Âpdb.gimp_selection_grow(image,dist+1) >>> Â Â Â Â Âouter=pdb.gimp_selection_save(image) >>> Â Â Â Â Âpdb.gimp_selection_load(selection) >>> Â Â Â Â Âpdb.gimp_selection_grow(image,dist) >>> Â Â Â Â Âinner=pdb.gimp_selection_save(image) >>> Â Â Â Â Âpdb.gimp_channel_combine_masks(outer,inner,CHANNEL_OP_SUBTRACT,0,0) >>> Â Â Â Â Âpdb.gimp_selection_load(outer) >>> Â Â Â Â Âimage.remove_channel(outer) >>> Â Â Â Â Âimage.remove_channel(inner) >>> >>> That works, but can be slow (especially since it's at the core of a >>> loop). Is there any better way? Or useless code to jettison? >>> >>> Next improvement is to create a 3-pixels selection and feather it one >>> pixel. Anything to be wary of? >> >> Hmm..this _will_ be slow. :-) >> >> You can speed it up by making a copy of your drawable to another >> image, disable the undo system on this new image Âand perform your >> cations above, before copying the results back to the original image - >> but it is about it. >> Maybe you can perform the whole loop in the copy with undo disabled - >> but I don't know your intent. > > Disabling undo on the main image (just for tests) doesn't show much > speed gain (from 2'03" to 1'56" in my test). It's only better memory-wise. > Hmm..maybe soem of the spped-up I experience has tod o with the new image I create on BG not being displayed - it will certainly help on this due to the marching ants that are used midway that don't need to show up. js -><- > _______________________________________________ > Gimp-developer mailing list > Gimp-developer@xxxxxxxxxxxxxxxxxxxxxx > https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer > _______________________________________________ Gimp-developer mailing list Gimp-developer@xxxxxxxxxxxxxxxxxxxxxx https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer