Python: basic operations on scikit-image Images
This example illustrates the basic operations on Python images.
Import numpy as npfrom skimage import dataimport matplotlib. pyplot as pltcamera = data. camera () # assign the value of the first 10 rows of the image to 0 camera [: 10] = 0 # search for a pixel mask with a pixel value less than 87 in the image = camera <87 # assign the found vertex to 255 camera [mask] = 255 # create index inds_x = np. arange (len (camera) inds_y = (4 * inds_x) % len (camera) # The pixel value of the corresponding index is 0 camera [inds_x, inds_y] = 0 # number of rows (high), number of columns (WIDE) l_x, l_y = camera. shape [0], camera. shape [1] # create a grid coordinate index X, Y = np. ogrid [: l_x,: l_y] # generate the circular grid coordinate outer_disk_mask = (X-l_x/2) ** 2 + (Y-l_y/2) ** 2> (l_x/2) ** 2 # assign 0 camera [outer_disk_mask] = 0 to the grid coordinates. # create the size ratio plt of the figure. figure (figsize = (4, 4) # display the image plt. imshow (camera, cmap = 'Gray ', interpolation = 'nearest') # Turn off the coordinate plt of the image. axis ('off') plt. show ()
Reference Source: http://scikit-image.org/docs/dev/auto_examples/