So I am trying to segment individual cells from a loaded image using Python/OpenCV. My code currently is able to mask the cells, but I would like to segment individual cells and save them as separate images.
So the output would be one of those single cells you see in the above (purposes for downstream use with 2D convnet)
img_dir = '/path'
img = cv2.imread(img_dir, 0)
plt.imshow(img, cmap = 'gray', interpolation = 'bicubic') # swap hot
for gray
# draw a contour image with fixed threshold 50
fig = plt.figure()
ax = fig.add_subplot(111)
ax.contourf(img, levels=[0, 10, 20, 30, 40, 50, 60, 70, 80, 120],
colors='k')
plt.show()
res = cv2.resize(img,None,fx=0.5, fy=0.5, interpolation =
cv2.INTER_CUBIC)