I have a figure that I get contour lines from a picture of face use by opencv (image below). I need to determine most curvature points of this contour in python (in the image, I need to define the red dots on right of the red line). How can I do it ?
Just find contour and compute curvature then find maximums: curvature
This article also may be useful: article
Related
I am working on a detection problem and I have found the mask of the object using cv2.findContours(). However, the found contour has a lot of noise and isn't smooth while the requirement is that it has to be smooth so we can use that smooth contour for our next step.
The obtained mask
The curve I want (the red line)
I have tried cv2.approxPolyDP() to reduce the noise but it is no longer a curve. I was asked to find a smooth curve.
The curve after using cv2.approxPolyDP()
Is there any way to do it?
I have the following image in which I've detected the borders, representing 7 circles. In my opinion, it is fairly easy to identify the circles on it, but I am having trouble detecting all circles with the opencv Hough transform. Here it is what I've tried:
img = cv2.imread('sample.png',0)
edges = cv2.Canny(img,20,120)
circles = cv2.HoughCircles(edges,cv2.HOUGH_GRADIENT,1,100,
param2=40,minRadius=0,maxRadius=250)
I either get the central circle, the outer one or a lot of circles, depending on the parameters I input on the function. Do you guys have a set of parameters that would output all the circles?
Thanks in advance
Solved with this example from scikit-image adjusting canny thresholds to match the posted image and also the radii range.
Thanks to #barny
I generated a hotspot map as shown here and now I want to calculate the area of each significant hotspot region. From the little research I've done, it seems as though I need to treat the contours as convex hulls and use Green's Theorem to calculate the area of the convex hulls.
However, I don't know how to translate this procedure into python code. Is there an easier method to achieve my goal?
I'm thinking of isolating all convex hulls that contain intensity greater than 3.2 (that is light blue, green, yellow, orange and red colors) and finding the area enclosed in those contours.
I would also like to count the number of points contained in the convex hulls generated.
Is there a simple way to do this using matplotlib?
Say we have the following contour information from OpenCV contours:
What I mean by a "region" is a subset of the contour with low directional variation.
So for example these, could be regions in the provided example:
One way to detect these could be, doing a local neighborhoud comparison of the dot products of the tangent at each point. (i.e see how much the tangent changes locally).
I was wondering however if there is a better way to do this, using OpenCV directly rather than doing vector operations myself.
-When your region boundaries are always near-vertical or near-horizontal, consider preprocessing the image using a filter (erode, dilate), to isolate vertices and horices, then merge results, to find an alternating color on region boundaries.
-When your directions go anywhere, it's more complicated ! One option would be to retrieve coordinates from your pixels with the help of Hough lines see
https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_imgproc/py_houghlines/py_houghlines.html
Good day.
I'm trying to analyze a human body contour using openCV. I already recognized head (topmost point of contour), left and right arms (leftmost and rightmost poitns), left and right legs (I split a body contour into two halves and found bottommost points). I also have shoulder points (topmost points between corresponding leg and foot).
But I also need to recognize armpits and I have no idea how to. Here's what I already have (red outline is my contour. I'm working with HSV image, if that even matters):
You must use findContour() and then convex hull here which could serve you better.