I would like to do the operation described on the attached image.
- Detect shapes in an image
- Move one of them
- Calculate the area In pixels of the overlap between these two shapes.
So far I managed to detect the edges using
cv2.findContours() First I would like to know if it is the right way or there is something more suitable for such task? Then how could I move only one of the shape detected and calculate the overlap area?
Thanks for your help
This is typically my data. I would like to detect the two horizontal dark “fingers”
I wanted to send a simplified version to make the explanation clear
and what do we see?
how you’d “move” this depends on why you want to move it and what it is.
the answer to “why” isn’t “because I want to intersect”. the answer ought to be why you want to do that, recursively, until you feel successfully interrogated.
resist the urge to be vague/academic.
various nice and simple and cheap pixel-wise operations could be applied… or others! depends on the situation!
You see the photons sent by your screen. I want to move it for my own pleasure.
Please don’t tell me what to do about why I want to do this or the way I am asking this question.
When I look at the picture above, I think it will be possible to some extent after going through the steps below.
First, leave only important areas to make it easier to recognize and remove the remaining images.
binarize the cut image. I think it would be better to give you an OTSU option.
Calculate the spacing on both sides in rows before the initial overlap.
When overlapping to some extent, use the slope or RAMP function to find the center of the overlapping area.
Scan from the top to the middle row and from the bottom to the middle row until the distance cannot be calculated.
Find the average error by collecting only the calculated intervals.
Uncalculated rows are calculated by inversely calculating the distance found in the first step.
In step 7, the sum of the distances inversely calculated will be the overlapping area.
However, if the two beams are completely overlapped and the spacing cannot be calculated, it is not known how much the overlap is.
Thanks a lot. I will try to go in this direction and will keep you posted