Reputation: 447
I am using skimage slic clustering algorithm to segment a biomedical image (whole slide image). When I plot the image with the segment boundaries I find that the boundaries are not well defined. Below is the my code and the corresponding image. When I use a even higher resolution image I still have the same problem. Is this because the clustering algorithm can't find well defined segments? Is there a way of obtaining a well defined boundary?
from skimage.segmentation import slic
from skimage.segmentation import mark_boundaries
import matplotlib.pyplot as plt
import cv2
image = cv2.imread('testPatch2.png')
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
segments = slic(image, n_segments=500, sigma=5, enforce_connectivity=True, convert2lab=True)
plt.figure(figsize=(10,10))
plt.imshow(mark_boundaries(image, segments, mode='thick'))
plt.show()
Upvotes: 2
Views: 571
Reputation: 5738
This is not an issue with the segmentation, but with the display. Matplotlib will by default crudely downsample the output image. See this question, those linked therein, and the answers, for more details. You can fix this in different ways:
dpi=300
(for example) to the plt.figure()
call.skimage.io.imsave
to save the image returned by mark_boundaries
, then open it with a standard image viewer.Upvotes: 2