This use case illustrates the basic operation of Python's image
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 0camera[:Ten] =0# Look for pixels with a pixel value less than 87 in the image .Mask = Camera < the# Assign a value of 255 to the found pointCamera[mask] =255# build an indexinds_x = Np.arange (len (camera)) Inds_y = (4* inds_x)% len (camera)# The pixel value of the corresponding index is assigned to 0Camera[inds_x, inds_y] =0# Gets the number of rows (high) of the image, the number of columns (width)l_x, l_y = camera.shape[0], camera.shape[1]# Create grid coordinate indexXY= np.ogrid[:l_x,: l_y]# Create a circular mesh coordinateOuter_disk_mask = (x-l_x/2)**2+ (Y-l_y/2)**2> (l_x/2)**2# assign 0 to grid coordinatesCamera[outer_disk_mask] =0# Build a figure size ratioPlt.figure (Figsize= (4,4))# Display ImagePlt.imshow (Camera, cmap=' Gray ', interpolation=' nearest ')# Turn off the coordinates of the imagePlt.axis (' off ') Plt.show ()
Reference Source: http://scikit-image.org/docs/dev/auto_examples/
Basic operation of Python:scikit-image image