Just starting off with cv2, what i want is giving a seed to the object as in some window of coordinates and have him connected all the pixels that might be outside the initial box of coordinates but in contact with it. I started with small tests to get a feel of connected componenets:
im=cv2.imread('test.png', 0)
ret, thresh = cv2.threshold(im, 254, 255, cv2.THRESH_BINARY)
output = cv2.connectedComponentsWithStats(thresh, 4, cv2.CV_32S)
then
im=cv2.imread('test.png', 0)
ret, thresh = cv2.threshold(im, 254, 255, cv2.THRESH_BINARY)
thresh = cv2.bitwise_not(thresh)
output = cv2.connectedComponents(thresh, 4, cv2.CV_32S)
both of these outpute arrays, ok so far so good then i wanted to see the actual output image referring to the docs https://docs.opencv.org/3.0-beta/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html#connectedcomponentsconnectedComponentsWithStats(InputArray image, OutputArray labels, OutputArray stats, OutputArray centroids, int connectivity=8, int ltype=CV_32S)
and labels – destination labeled image
so i changed the last line in the small code shared above to this:
output = cv2.connectedComponents(thresh,"out_test.png" ,4, cv2.CV_32S)
and it gave me the error shared in the question.i also tried:
cv2.imwrite(dest_dir+"out_test.png", output)
and got this error:
TypeError: img is not a numerical tuple
how can i actually visualize the output as i don't want to count the blobs(objects), their sizes or anything else i just want them to grow from the original region of interest i give.