How to find missed corners outside the image - python

The task is: Find all 4 corners of a given red polygon on this image
I know how to find all corners if all borders are visible (linear extrapolation, phew, easy).
My question is how to go about finding bottom corners if we don't see the bottom border?

The answer is quite simple. You can't.
If you don't have both dimensions of your rectangle you cannot find missing corners. You cannot know how far that rectangle extends outside your image.
For your example the only way would be to assume that corner 3 is on the image border. Then you can calculate the missing 4th corner.

Related

Corner detection: getting rid of unwanted corners

I'd like to find the corners of the following box
However, as you can see I'm detecting a lot of corners I don't want to find. I'm completly stuck on this one. No matter what I try, I always seem to find corners in the dots on the box. I used the function goodFeaturesToTrack() but I also tried cornerHarris()
The most important thing to me is to find the coordinates of the corner pixels so I can draw a wire frame.
Kind regards, Schweini
Edit:
To draw the wire frame onto the image, following process can be thinkable.
When extracting outline of the black box region, the outline consists with 6 straight line segments.
Therefore, you'll able to find at least 6 corners of the box as the intersection of each two adjacent line segments.
Additionally, it looks like that, outline of 6 surfaces of the box will be able to coarsely estimated from each adjacent line segment pairs. (with assuming parallelogram)
This means estimating the positions of the remaining two corners (to draw the wire frame).
Furthermore, if you want, comparing the estimation result with your examination (corner detecition) result will be able to refine the coordinates of one corner.

Finding the center of these pictures, OpenCV-Python

I want to find the exact center of these attached images. The things I've tried:
1- HoughCircles, but it didn't work because it's not a perfect circle...
2- Thresholded the picture, so it's all black and white -> contour -> center of contour. This doesn't work on both of these images. It gives a center which isn't correct.
Does one of you know another approach I can try?
EDIT: In the first image, you can see why just taking the center with the contour doesn't work. It's not perfectly in the center of the 'circle'
EDIT2: The definition of the center can be seen in the second image where the circle touches all the 'sides' at the same moment
Thanks,
Try the following:
Threshold the image using the OTSU-Method (which will leave you with a binary image, where only the middle section should be kept. Maybe you have to modify the actual threshold value a little bit)
On the thresholded image find the center using image moments (see e.g. https://docs.opencv.org/3.4/d0/d49/tutorial_moments.html)
This assumes, that the middle section will always be brighter in comparison to the area outside.
One way you could try:
Find corners
Clean up outliers
Average their locations
I expect that to be quite in the center.
If not, please define the question more precisely.

Python Fit circle with center outside of image

I have the following binary image of a disk, and extracted the border of it:
How can I calculate the center and the radius of the circle? I already tried some methods with cv2.HoughCircles() and cv2.findContours() + cv2.fitEllipse(), however these don't work with images where the circle center is far outside of the image.
You can find center of circle from 3 points, but for robust solution it is better to use ransac method. It uses a set of different solutions, for all your bounding points set and will give you more accurate solution. For instance check : here

Fill Contour/Pixels within other Contours | Detecting Boxes using Depth Images

I'm using OpenCV to find boxes within a depth grayscale image.
First, I cut the depth image from the top of the box as shown below:
Next, I cut the depth image from the bottom of the box as shown below:
After some filtering, closing and doing some basic operations, I get an image of the top cut merged with where the box bottoms are along with bounding boxes. Please see the image below:
The goal now is to attempt to stretch the inner rectangles until they touch the corners of the top edges. The issue is that the boxes could be rotated which makes filling much harder than just looping horizontally/vertically and filling in gaps.
An approach would be getting a side of the inner rectangle, keep moving it in the direction of stretching until it touches some pixels of value 255. However, this takes a lot of time and isn't efficient.
Another approach is eliminating all pixels that aren't along the direction of stretching the segment, finding the contours of the remaining objects, and attempting the same method.
A third approach and the one that makes most sense to me:
Draw the other 2 segments connected to the side of the rectangle but as lines so to fill the entire image.
Anything outside the 2 lines is ignored
Find get a list of coordinates of the contours of the remaining objects in the direction of stretching/filling
Find the closest pixel to the side; this is where we'll stretch the box to
This is still rather inefficient.
Any help, guidance, or insights would be much appreciated. Thank you!

Detecting center of image from parabolic mirror?

I have a panoramic one shot lens from here: http://www.0-360.com/ and I wrote a script using the python image library to "unwrap" the image into a panorama. I want to automate this process though, as currently I have to specify the center of the image. Also, getting the radius of the circle would be good too. The input image looks like this:
And the "unwrapped" image looks like this:
So far I have been trying the Hough Circle detection. The issues I have is selecting the correct values to use. Also, sometimes, dark objects near the center circle seem to throw it off.
Other Ideas I had:
Hough Line detection of the unwrapped image. Basically, choose center pixel as center, then unwrap and see if the lines on the top and bottom are straight or "curvy". If not straight, then keep trying with different centers.
Moments/blob detection. Maybe I can find the center blob and find the center of that. The problem is sometimes I get a bright ring in the center of the dark disk as seen in the image above. Also, the issue with dark objects near the center.
Paint the top bevel of the mirror a distinct color like green to make circle detection easier? If I use green and only use the green channel, would the detection be easier?
Whats the best method I should try and use to get the center of this image and possibly the radius of the outer and inner rings.
As your image have multiple circle with common centre you can move that way, like
Detect circle with Hough circle and consider circle with common centre.
Now check the ratio for co-centred circle, as your image keep that ratio constant.
I guess don't make it too fancy. The black center is at the center of the image, right? Cut a square ROI close to the image center and look for 'black' region there. Store all the 'black' pixel locations and find their center. You may consider using CMYK color space for detecting the black region.

Categories

Resources