In this article we will see how we can load the image as grey in mahotas, there are lots of images available in mahotas we use mahotas.demos.load method to load them, in this tutorial we will use “luispedro” image, below is the command to load it.
mahotas.demos.load('luispedro')
Below is the luispedro image

In order to do this we will use mahotas.demos.load method
Syntax : mahotas.demos.load(‘luispedro’, as_grey=True)
Argument : It takes image name as argument
Return : It returns numpy.ndarray i.e image object
Example 1:
# importing required librries import mahotas import mahotas.demos import numpy as np from pylab import imshow, gray, show from os import path # loading the image photo = mahotas.demos.load('luispedro') # showing original image print("Origial Image") imshow(photo) show() # loading image as grey photo = mahotas.demos.load('luispedro', as_grey = True) # showing image print("Image loaded as grey") imshow(photo) show() |
Output :

Example 2:
# importing required librries import mahotas import mahotas.demos import numpy as np from pylab import imshow, gray, show from os import path # loading the image photo = mahotas.demos.load('luispedro') # showing original image print("Origial Image") imshow(photo) show() # loading image as grey photo = mahotas.demos.load('luispedro', as_grey = True) # converting image type to unit8 # beacuse as_grey returns floating values photo = photo.astype(np.uint8) # calling gray method gray() # showing image print("Image loaded as grey") imshow(photo) show() |
Output :

Recommended Posts:
- Loading Image using Mahotas - Python
- Mahotas - Reconstructing image from transformed Daubechies wavelet image
- Mahotas - Labelled Image from the Normal Image
- Mahotas - Getting Mean Value of Image
- Mahotas - Dilating Image
- Mahotas - Resizing Image
- Mahotas - Image Overlay
- Mahotas - Getting Image Moments
- Mahotas - Eroding Image
- Mahotas – Convolution of Image
- Mahotas - Roundness of Image
- Mahotas - Eccentricity of Image
- Mahotas - Image Stretch RGB
- Mahotas – Creating RGB Image
- Mahotas - Cropping Image
- Mahotas - Image Stretching
- Mahotas – Closing Holes in Image
- Mahotas – Euler number of Image
- Mahotas – Image Cropped to bounding box
- Mahotas – Conditional Eroding Image
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

