📜  Mahotas – 图像拉伸 RGB

📅  最后修改于: 2022-05-13 01:55:36.518000             🧑  作者: Mango

Mahotas – 图像拉伸 RGB

在本文中,我们将了解如何在 mahotas 中对 RGB 图像进行拉伸。对比度拉伸(通常称为归一化)是一种简单的图像增强技术,它试图通过“拉伸”图像包含的强度值范围以跨越所需的值范围来提高图像的对比度,例如像素值的整个范围。有关的图像类型允许。 RGB 拉伸是stretch()函数的变体,可在RGB 图像上按通道工作

在本教程中,我们将使用“lena”图像,下面是加载它的命令。

mahotas.demos.load('lena')

下面是莉娜的图片

下面是实现

Python3
# importing required libraries
import mahotas
import mahotas.demos
from pylab import gray, imshow, show
import numpy as np
import matplotlib.pyplot as plt
   
# loading image
img = mahotas.demos.load('lena')
   
print("Image")
   
# showing image
imshow(img)
show()
 
# stretching rgb image
new_img = mahotas.stretch_rgb(img)
  
 
# Stretched image
print("Stretched Image")
imshow(new_img)
show()


Python3
# importing required libraries
import mahotas
import numpy as np
from pylab import gray, imshow, show
import os
import matplotlib.pyplot as plt
  
# loading image
img = mahotas.imread('dog_image.png')
 
   
print("Image")
   
# showing image
imshow(img)
show()
 
# stretching image
new_img = mahotas.stretch_rgb(img)
  
 
# Stretched image
print("Stretched Image")
imshow(new_img)
show()


输出 :

Image

Stretched Image

另一个例子

Python3

# importing required libraries
import mahotas
import numpy as np
from pylab import gray, imshow, show
import os
import matplotlib.pyplot as plt
  
# loading image
img = mahotas.imread('dog_image.png')
 
   
print("Image")
   
# showing image
imshow(img)
show()
 
# stretching image
new_img = mahotas.stretch_rgb(img)
  
 
# Stretched image
print("Stretched Image")
imshow(new_img)
show()

输出 :

Image

Stretched Image