O'Reilly logo

Computer Vision with Python 3 by Saurabh Kapur

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Superpixels

Images are always dealt with by the granularity of a pixel. But this can sometimes be computationally expensive. You do not always want to iterate through all the pixels in the image. As an attempt to remove redundancy in the pixels of an image, we try to combine pixels closer to each other that have the same color value into a cluster and then call those clusters superpixels. The advantage of doing this is that now instead of going through a few pixels we just go through one superpixel, which is nothing but a combination of these pixels.

The following code computes the superpixels in an image:

from skimage import segmentation, colorfrom skimage.io import imreadfrom skimage.future import graph from matplotlib import pyplot as ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required