Gimp-Forum.net
Cropping and slicing a path - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP)
+--- Thread: Cropping and slicing a path (/Thread-Cropping-and-slicing-a-path)

Pages: 1 2 3


RE: Cropping and slicing a path - Krikor - 01-19-2021

(01-19-2021, 02:08 PM)Ottia Tuota Wrote: Fine, I shall look into the problem. Would you kindly post and attach the .xcf file. It would make debugging easier.

Just a 300 radius circle where I applied the plug-in. Attached is the xcf.[attachment=5504]


RE: Cropping and slicing a path - Ottia Tuota - 01-21-2021

Thanks, Krikor.

I think I got it fixed now. The new version is 0.5, in the same place as before:

http://kmarkku.arkku.net/Path_crop_files/Gimp_master.html

Please report if any more errors occur. In the previous version I had overlooked the possibility that a splitting point may fall on an anchor of the path. I hope I got it now right, but it is rather complicated and I may still have missed something.

I know one more a little disturbing behaviour. A stroke, if it meets the cropping circle, is divided into two strokes even when that would not be necessary. I may do something about that in the future, or then I may not...


RE: Cropping and slicing a path - denzjos - 01-21-2021

Works fine for me, ball of yarn :
[attachment=5526]


RE: Cropping and slicing a path - Krikor - 01-21-2021

(01-21-2021, 12:30 PM)Ottia Tuota Wrote: Thanks, Krikor.

I think I got it fixed now. The new version is 0.5, in the same place as before:

http://kmarkku.arkku.net/Path_crop_files/Gimp_master.html

Please report if any more errors occur. In the previous version I had overlooked the possibility that a splitting point may fall on an anchor of the path. I hope I got it now right, but it is rather complicated and I may still have missed something.

I know one more a little disturbing behaviour. A stroke, if it meets the cropping circle, is divided into two strokes even when that would not be necessary. I may do something about that in the future, or then I may not...

With version 0.5 and using the same .xcf as before, the results were as expected.

Thanks for the correction and update of this plugin.


RE: Cropping and slicing a path - Ottia Tuota - 03-30-2021

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/Gimp_master.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.

[attachment=5811]

I did:
  1. Path to selection from the red path.
  2. Call the new plugin "crop path by general selection" (choosing the inside-outside option to be "both").
I got two paths. Here I display them separately. The red path does not belong to the cropped paths.

[attachment=5812]

[attachment=5813]

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.


RE: Cropping and slicing a path - Ofnuts - 03-30-2021

(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/Gimp_master.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:
  1. Path to selection from the red path.
  2. Call the new plugin "crop path by general selection" (choosing the inside-outside option to be "both").
I got two paths. Here I display them separately. The red path does not belong to the cropped paths.





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).


RE: Cropping and slicing a path - Ottia Tuota - 03-30-2021

Ah well, so it is not finished yet, after all. And I was hoping to get to that other project...

But thanks. I'll come back with questions if needed.


RE: Cropping and slicing a path - Krikor - 03-30-2021

I was not able to use the plug-in, there were always windows with error messages.
I tried with Truchet shapes, and finally got a functional result.

Are there any specifications or limitations on what kind of paths the plug-in might not be applied to?

Below are some examples.
01- With truchet, OK.
[attachment=5816]
02- With checkers, Not ok.
[attachment=5817]
03- Not ok again.
[attachment=5818]

Thanks for the plug-in!


RE: Cropping and slicing a path - Ottia Tuota - 03-30-2021

There should be no limitations. You have found bugs. I shall look at this tomorrow. It would help if you could run those trouble cases again and expand that "More information" in the error message and post here.


Edit: I think I found the reason for the first error. As for the second error, is the path the same checker, only denser? If so, then perhaps the error too comes from the same bug. It will be fixed in the next version where I hope I shall have also incorporated what Ofnuts just taught me.


RE: Cropping and slicing a path - Krikor - 03-30-2021

(03-30-2021, 08:32 PM)Ottia Tuota Wrote: There should be no limitations. You have found bugs. I shall look at this tomorrow. It would help if you could run those trouble cases again and expand that "More information" in the error message and post here.


Edit: I think I found the reason for the first error. As for the second error, is the path the same checker, only denser? If so, then perhaps the error too comes from the same bug. It will be fixed in the next version where I hope I shall have also incorporated what Ofnuts just taught me.

Ok,

(03-30-2021, 08:32 PM)Ottia Tuota Wrote: Edit: I think I found the reason for the first error. As for the second error, is the path the same checker, only denser? If so, then perhaps the error too comes from the same bug. It will be fixed in the next version where I hope I shall have also incorporated what Ofnuts just taught me.

Different cut paths, same base path.
[attachment=5820]