Mahotas – RGB to Sepia Conversion
Last Updated :
29 May, 2021
In this article we will see how we can covert rgb image to sepia in mahotas. An RGB image, sometimes referred to as a truecolor image, is stored in MATLAB as an m-by-n-by-3 data array that defines red, green, and blue color components for each individual pixel. Sepia-toning effect is used very commonly in photography. It is the process of changing the intensity on every pixel color of a gray-scale image, or so-called black-and-white.
In this tutorial we will use “lena” image, below is the command to load it.
mahotas.demos.load('lena')
Below is the lena image
In order to do this we will use mahotas.colors.rgb2sepiamethod
Syntax : mahotas.colors.rgb2sepia(img)
Argument :It takes image object as argument
Return : It returns image object
Below is the implementation
Python3
import mahotas
import mahotas.demos
from pylab import gray, imshow, show
import numpy as np
img = mahotas.demos.load( 'lena' )
print ( "Image" )
imshow(img)
show()
new_img = mahotas.colors.rgb2sepia(img)
print ( "New Image" )
imshow(new_img)
show()
|
Output :
Image
New Image
Another example
Python3
import mahotas
import numpy as np
import matplotlib.pyplot as plt
import os
img = mahotas.imread( 'dog_image.png' )
img = img[:, :, : 3 ]
print ( "Image" )
imshow(img)
show()
new_img = mahotas.colors.rgb2sepia(img)
print ( "New Image" )
imshow(new_img)
show()
|
Output :
Image
New Image
Share your thoughts in the comments
Please Login to comment...