numpy.where() on grayscale frame, wrong indices

asked 2015-06-06 08:06:27 -0500

0 down vote favorite

I'm trying to implement a basic RANSAC algorithm for the detection of a circle in a grayscale image.

The problem is that, after I thresholded the image and I search for non-zero pixels I get the right shape, but the points are somehow delocalized from the original position:

video = cv2.VideoCapture('../video/01_CMP.avi')
succ, frame =

frame = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
frame = cv2.normalize(frame,frame, alpha=0,norm_type=cv2.NORM_MINMAX, beta = 255)
ret,frame = cv2.threshold(frame,35,255,cv2.THRESH_BINARY)

points = n.where(frame>0) #Thresholded pixels

#Orienting correctly the points in a (n,2) shape
#needed because of arguments of circle.points_distance()
points = n.transpose(n.vstack([points[0],points[1]]))



image description

edit retag flag offensive close merge delete