Basic operation of Python:scikit-image image

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.