Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script to detect and select simple shapes?
#7
(09-22-2024, 08:51 AM)tomatoSauce23 Wrote:
(09-22-2024, 08:13 AM)Ofnuts Wrote: Ok, so the question you are asking is a typical one for computer vision, so maybe you should learn Python (which is very easy if you already have programming experience) and check the openCV library.

With Gimp, I would try this:
  • The color selection can use a RGB color but also  tint, hue, saturation, lightness, or any of the RGB channels, all with a threshold.
  • From a selection you can obtain a path. This will rarely be exactly 4 points in a square, even if the shape is rectangular
  • From the path anchors you can determine corners (extremums on X/Y)
  • From these 4 corners you can create a selection a bucket-fill a layer
  • From the initial path you can obtain a selection and bucket-fill another layer
  • You put the top layer in Difference mode and merge the layer. The resulting layer is a map of the differences
  • With the histogram function you can have the pixel count of the difference and see how big that is relative to the square
Now out to hide the pool in my backyard.

Thank you. So, I hadn't ever heard of computer vision before, and a quick look suggests to me that the openCV library is a library of programmes written in the common programming languages for various tasks that people have use for. So, am I right to think that you are advising that I go there and see if there is already a programme available to do the task that I'm asking about? and if so, then I guess that all would happen outside of Gimp and inside whichever programming language I choose (Java, for example). So I'd find a programme in the openCV library that would find those squares in my images and crop those images to those squares. 

As for those Gimp instructions, I reckon I could follow them manually... and then are you saying that it would then be possible to write a Python script that does all of those steps as a plugin?

Yes to both.
Reply


Messages In This Thread
RE: Script to detect and select simple shapes? - by Ofnuts - 09-22-2024, 09:32 AM

Forum Jump: