No account yet ?
Tested in Anaconda and Python 3.7
from matplotlib import pyplot as plt face_image = plt.imread('pexels-elias-de-carvalho-1375849.jpg') # Import the slic function from segmentation module from skimage.segmentation import slic # Import the label2rgb function from color module from skimage.color import label2rgb def show_image(image, title='Image', cmap_type='gray'): plt.imshow(image, cmap=cmap_type) plt.title(title) plt.axis('off') plt.show() nb_pixels = 50 for i in range(10): nb_pixels *= 2 # Obtain the segmentation with 400 regions segments = slic(face_image, n_segments = nb_pixels) # Put segments on top of original image to compare segmented_image = label2rgb(segments, face_image, kind='avg') # Show the segmented image show_image(segmented_image, "Segmented image, %s superpixels" % (nb_pixels)) plt.imsave('Segmented-image-%s-superpixels.jpg' % (nb_pixels), segmented_image)
plotly
Copyright (c) 2019 Leonardo Ferreira
100 pixels
200 pixels
400 pixels
800 pixels
1600 pixels
3200 pixels
6400 pixels
12800 pixels
25600 pixels
51200 pixels
Welcome, my name is Eric Soupet and I am the administrator of the site elodees.com. elodees.com is a state of the art of Artificial Intelligence and aims to be collaborative, you can now offer content such as articles, events, tutorials, ... so don't hesitate !
Platform images credit : Pixabay - Pixabay License | Pexels - Pexels License