03-30-2021, 03:07 PM
(03-30-2021, 01:38 PM)Ottia Tuota Wrote: I added a new path-cropping plugin: Crop a path by a general selection. The new version is 0.6 and it is in the same place as before:
http://kmarkku.arkku.net/Path_crop_files...aster.html
It seems to work correctly though it is slow. Please report any erronous behaviour.
As an example I use the Truchet path. Here I have drawn an additional path (red) from which to make a selection.
I did:
I got two paths. Here I display them separately. The red path does not belong to the cropped paths.
- Path to selection from the red path.
- Call the new plugin "crop path by general selection" (choosing the inside-outside option to be "both").
The input "Threshold" is meaningful if your selection is feathered.
In complicated cases the plugin is slow (the above run takes some 31 seconds), which is mainly due to the large number of calls to image.selection.get_pixel(). There may be some way to restrict that number of calls, but that would require further complication of the code. And it may not be so efficient after all. Currently I am not willing to try it. Going now to another project. Happy for having finished this. Please have fun.
There is a much more efficient way than get_pixel(). You can use a pixel_region, which ends up as an array directly usable in Python. Some exemple [here](https://www.gimp-forum.net/Thread-Gimp-python-and-numpy) (before the conversion to a numpy array of course).