Posts: 12
Threads: 5
Joined: Sep 2024
Reputation:
0
Operating system(s):
- Windows Vista or 7, 8, 10 (64-bit)
Gimp version: 2.10
I'd like a plugin to be able to detect and then select simple shapes in a layer or image. So there is a green square in lots of pictures I'm processing and I have to mark them every time they occur, so I do this manually using the Rectangle tool. The squares are always of a similar size and colour. Is there a plugin that could detect squares within a certain size-range and colour-range and then select them? If not, how difficult would it be to write a script like that, given that I have some programming experience but not in Python?
Posts: 6,340
Threads: 272
Joined: Oct 2016
Reputation:
563
Operating system(s):
Gimp version: 2.10
I remember answering that question yesterday on GimpChat?
Posts: 1,512
Threads: 69
Joined: May 2021
Reputation:
167
Operating system(s):
Gimp version: 2.10
(09-22-2024, 07:08 AM)Ofnuts Wrote: I remember answering that question yesterday on GimpChat?
I saw nothing on GC about that
Patrice
Posts: 12
Threads: 5
Joined: Sep 2024
Reputation:
0
Operating system(s):
- Windows Vista or 7, 8, 10 (64-bit)
Gimp version: 2.10
(09-22-2024, 07:08 AM)Ofnuts Wrote: I remember answering that question yesterday on GimpChat?
Hi, this problem is interfering I think...
Posts: 6,340
Threads: 272
Joined: Oct 2016
Reputation:
563
Operating system(s):
Gimp version: 2.10
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.
Posts: 12
Threads: 5
Joined: Sep 2024
Reputation:
0
Operating system(s):
- Windows Vista or 7, 8, 10 (64-bit)
Gimp version: 2.10
(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?
Posts: 6,340
Threads: 272
Joined: Oct 2016
Reputation:
563
Operating system(s):
Gimp version: 2.10
(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.
Posts: 12
Threads: 5
Joined: Sep 2024
Reputation:
0
Operating system(s):
- Windows Vista or 7, 8, 10 (64-bit)
Gimp version: 2.10
(09-22-2024, 09:32 AM)Ofnuts Wrote: (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.
Thanks. As it happens I just wrote a Java programme to do it for me in the end which was relatively straight-forward to do.
|