Ask Your Question

anandvd's profile - activity

2020-05-14 01:20:54 -0600 received badge  Notable Question (source)
2019-12-12 15:45:31 -0600 received badge  Popular Question (source)
2017-07-26 07:58:46 -0600 commented question Accessing ALL points of a contour

I am trying to see all the black doublets in a straight line. I have tried using toPolar() but it gives me a distorted image like this. Since this approach didn't work well, I am now trying to extract each doublet (which will be contained in a "pizza slice" like shape, centered at the center of the image) and place them next to each other.

2017-07-26 07:00:24 -0600 commented question Accessing ALL points of a contour

Thanks for the comment! What confuses me, is that since all points on the image are not connected, how can I make a contour surrounding just the image? (similar to what the hull gives, but a contour)

2017-07-26 05:23:19 -0600 asked a question Accessing ALL points of a contour

image description

I made the exterior contour using the following:

def contoursConvexHull(contours):
    pts = []
    for i in range(0, len(contours)):
        for j in range(0, len(contours[i])):
            pts.append(contours[i][j])

    pts = np.array(pts)
    result = cv2.convexHull(pts)
    return result

image = cv2.imread(args["image"])
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (5,5), 0)
thresh = cv2.threshold(blurred, 60, 255, cv2.THRESH_BINARY)[1]
imageCanny = cv2.Canny(blurred, 100, 200, 3)

img, contours, hierarchy = cv2.findContours(imageCanny, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

ConvexHullPoints = contoursConvexHull(contours)
cv2.polylines(image, [ConvexHullPoints], True, (0,255,255), 2)

and accessed the center of the contour using the following:

c = max(contours, key = cv2.contourArea)
M = cv2.moments(c)
if M["m00"] != 0:
    cX = int(M["m10"] / M["m00"])
    cY = int(M["m01"] / M["m00"])
    print (cX,cY)
else:
    cX, cY = 0,0
    print (cX,cY)

My questions: 1. Since my image is not continuous, am I right in using convexHull and polylines() to draw the contour? 2. If I am right in using the above functions, how can I access ALL the points on the convexHull contour? Currently, if I use

cpts = []
cpts.append(ConvexHullPoints)
cpts = np.array(cpts)
print (cpts)

to see the points, I only get an array of 35 points.

2017-07-18 10:39:04 -0600 asked a question 3D image slicing and 2D projection

Is there a way in OpenCV to slice a 3D image into its constituent 2D slices. For example, cutting a 3D cylinder along planes parallel to its base

image description

OpenCV3, Python3.5.1

2017-07-13 03:44:50 -0600 received badge  Enthusiast
2017-07-12 11:05:25 -0600 commented answer cv2.linearPolar() TypeError

It works! Thanks! But in the documentation it mentions the destination as a parameter as well

2017-07-12 11:03:46 -0600 received badge  Supporter (source)
2017-07-12 10:56:46 -0600 commented question cv2.linearPolar() TypeError

I tried making it float, but still getting the same error

2017-07-12 10:51:28 -0600 received badge  Editor (source)
2017-07-12 10:40:43 -0600 asked a question cv2.linearPolar() TypeError

I am trying to convert concentric circles into straight lines using linear polar:

circleArr = np.ndarray((512,512), dtype = np.float32)
for i in range(10,600,10):
    cv2.circle(circleArr, (256,256), i-10, np.random.randint(60,500), thickness = 4)

lp = np.ndarray((512,512), dtype=np.float32)
img1 = cv2.linearPolar(circleArr, lp, (256,256), 100, cv2.INTER_LINEAR+cv2.WARP_FILL_OUTLIERS)

I get the following error referring to the last line:

TypeError: a float is required

I am confused because both the input and output array in the linearPolar() function are float type

Opencv3 and python 3.5.1

2017-07-11 06:11:57 -0600 received badge  Scholar (source)
2017-07-10 03:37:13 -0600 asked a question "Cutting open" a 3D .mrc file

C:\fakepath\microtubule.jpg

I have a 3D .mrc file of cilia microtubules which was generated using electron microscopy. It is a cylindrical image, and I am trying to "cut it open" along the central axis to flatten it (still a 3D image). I am attaching a sample image of how it might look. Please help!