detecting the center of an arc by using open cv [closed] - python

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am trying to detect the center&radius of an arc like shown below for my thesis by using open cv. I tried many things and searched a lot, but cant figure out. Could please somebody help me? I would be really glad.

I would not do the center finding itself with OpenCV but with simple 2D geometry instead see first bullet in Circular approximation of polygon (or its part) so:
filter out blobs not on curve
segmentate and remove too small (unconnected) blobs
find 3 points on your curve
They should be far enough from each and should form 2 lines (black). You can apply thinning algorithms to enhance precision. than simply find 2 most distant points from the curve and one that is in half way between them.
cast normal axises from their mid points (brown)
simply rotate the line slope by 90 deg by swapping x,y of direction vector and negating one of them so (-y,x) or (y,-x).
find the intersection its the center you are looking for
find radius
its the average of distance between center and the 3 points ...
Here a small example I just did in paint (its hand drawn so not pixel perfect):

Here is my simple approach algorithm:
Look at the angle contour by wide-view, like:
Check each pixel of this wide-view image one by one and find the norms(lengths) for each point of the contours. (To be clear: for each pixel, find lengths to those contour points)
If all lengths are equal for a pixel then that pixel is the center of the circle.
Note: This is simple approach and absolutely works. Just not sure about does it take long time to calculate for cpu.

Related

Finding the top edge of a disk [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 days ago.
Improve this question
I have a stock of photos, of a spinning disk of varying angles. I wish to find the edge of the top of the disk. The top is colored in a distinct black color in comparison to the rest of the photo.
A
B
I first tried using canny edge detection which does a decent job, but also identifies the bottom half of the disk, which I wish to avoid.
Next idea was to use the distinct black color- perhaps by dividing the photo into domains characterized by colors\intensities- and by choosing the largest domain\most black domain or some other parameter, perhaps to isolate that black circle, and only then to use canny edge detector.
Is there any existing function that can divide a greyscale image into domains? Transferring from matlab to python, so I'm new to it's syntax and functions.
Thanks
The Canny disaster goes on !
People playing with image processing keep willing to rely on edge detection when they have beautifully segmenting scenes. With a careful selection of a binarization threshold, you can extract the ellipse as a single piece.

Is there a way to find the speed from analog speedometer? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I have an analog speedometer image, with the needle pointing to the current speed. I am trying to find a way to get the speed that the needle is pointing out to. I tried using HoughCircles() from OpenCV, but it is throwing an error as the image contains only speedometer and which is a semi-circle. Any resources to help me move forward will be appreciated.
Assuming the needle will have a different colour to the rest of the speedometer OR its size is distinctly larger than the rest of the elements on the speedometer (which is often the case), I'll do something like below.
Convert the image to grayscale.
Apply colour thresholding (or size-based thresholding) to detect the pixel area representing the needle.
Use HoughLines() or HoughLinesP() functions in OpenCV to fit a line to the shape you detected in Step 2.
Now it's a matter of measuring the angle of the line you generated in Step 3 (example provided here: How can I determine the angle a line found by HoughLines function using OpenCV?)
You can then map the angle of the line to the speed through a simple equation (Will need to see an image of the speedometer to generate this).
let me know how it went.

Image processing- how to check which Star is closer and which Star is farther in a space image [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Let's say we pick an image of space. Let's assume there is big star at 40 light years away and a smaller star 20 light years away. But when we look at the image both would look same size. How can we identify which is bigger and which is smaller by size and how far is it from us.
I want to do image processing on these images.
Keywords: Astronomy, space telescope, stars machine learning, opencv, python.
Short answer: It is impossible.
Long answer: You need additional information, such as light emission from each star and received by the camera (if they are equal, the closer star will be brighter). Using only size in pixels you cannot determine even the relative distance between them as they may differ in the size and distance to the observer (the star with radius r and distance d is projected exactly the same as the star with radius 2r and distance 2d).
Unfortunately, it is not straightforward to infer the distance from the size by just looking at your image. You could make guesstimates on the stars' relative distance by comparing their colors (aka temperatures). However, this requires you to have accurate UBV measurements (quite some other filter systems also work).
If you know (or can identify) the stars in your image, you could look up any relevant information on public databases.
Types of measurements that allow you measure the distance to a star are their parallax, their color, or in some cases it can be inferred from their variability.
You can't tell from the image alone, you need to know the apparent and absolute brightness of each star, their temperature, spectrum, and other characteristics to know which star is the brightest in compare to the others.

Make a Yin-Yang circle [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I've been trying to attempt a Yin-Yang circle on Python, but so far I've only been able to do a black semi-circle. In here I've attached what it looks like for me and what it's supposed to look like. What else should I add to my code?
*to make it easier for me to understand, use fill function when coloring.
My Code:
import turtle
turtle.begin_fill()
turtle.circle(50,180)
turtle.end_fill()
turtle.hideturtle()
What it looks like for me:
results
How it's supposed to be:
desired results
You are pretty close already, if you think of the yin-yang symbol mathematically, it's just a bunch of arcs, two large ones on the outside, and two on the inside, half the length.
If the outside arcs have a length of 50, then the internal arcs need to be 25. Turtles move counter-clockwise by default, so to get a clockwise curve, use a negative radius. Like so:
turtle.begin_fill()
turtle.circle(50, 180)
turtle.circle(25, 180)
turtle.circle(-25, 180)
turtle.end_fill()
turtle.circle(-50, 180)
After that, the turtle will back where it started, and the positions for the circles should be roughly a quarter and three quarters of 50 directly below the turtle, where you just need to make two full circles.
As much as I like #CameronFerguson's single curve approach (+1), it might be easier for a beginner to think of this as simply five circles. The first, largest circle is filled on one side, as you have already achieved. The next two circles are half the radius of the original, centered on the vertical axis, and opposite colored:
Choose a size for the smallest two circles, above they are 1/8th of the original radius, use the same center point as the previous circles and reverse the color again. Now, switching to the final colors, and raising the pen appropriately to avoid unwanted lines, we get:
With some additional thought, the two sets of inner circles can done in a loop, cutting the number of calls to turtle.circle() in half. But if you're comfortable with #CameronFerguson's curve approach, go with that!

Area of Polygon - spyder [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a really hard task to do, which is to calculate the area of the polygon using earlier created script in PYTHON to read the data from a set of Polygons stored in Well Known Text format and calculate the area for each Polygon using the formula..(I don't know the actual formula... I know it's theformula to calculate the area of a polygon using the summation of triangles.)
then script should read the data from the file and store it as a list or lists. The script should compute the polygon area and save the areas of each polygon to a file and also script should use a function to calculate the area of the polygon.
Please help, as I have no idea how to do it in python(never used it before). You are my last chance people!
You can use shapely library to calculate the area.
https://pypi.python.org/pypi/Shapely
Create a Polygon using the coordinates of the vertices of the polygon.
poly = Polygon([list of point pairs])
The area of the polygon is returned by:
poly.area

Categories

Resources