📜  Mahotas – Haralick 功能

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

Mahotas – Haralick 功能

在本文中,我们将了解如何在 mahotas 中获取图像的 haralick 特征。 Haralick 纹理特征是根据灰度共现矩阵 (GLCM) 计算的,该矩阵计算图像中相邻灰度的共现。 GLCM 是一个方阵,其维度为感兴趣区域 (ROI) 中的灰度级数 N。为此,我们将使用来自核分割基准的荧光显微镜图像。我们可以在下面给出的命令的帮助下获取图像

mahotas.demos.nuclear_image()

下面是nuclear_image

为此,我们将使用 mahotas.features.haralick 方法

注意: this 的输入应该是过滤后的图像或加载为灰色
为了过滤图像,我们将获取图像对象 numpy.ndarray 并在索引的帮助下对其进行过滤,下面是执行此操作的命令

image = image[:, :, 0]

示例 1:

Python3
# importing various libraries
import mahotas
import mahotas.demos
import mahotas as mh
import numpy as np
from pylab import imshow, show
 
# loading nuclear image
nuclear = mahotas.demos.nuclear_image()
 
# filtering image
nuclear = nuclear[:, :, 0]
 
# adding gaussian filter
nuclear = mahotas.gaussian_filter(nuclear, 4)
 
# setting threshold
threshed = (nuclear > nuclear.mean())
 
# making is labeled image
labeled, n = mahotas.label(threshed)
 
# showing image
print("Labelled Image")
imshow(labeled)
show()
 
# getting haralick features
h_feature = mahotas.features.haralick(labelled)
 
# showing the feature
print("Haralick Features")
imshow(h_feature)
show()


Python3
# importing required libraries
import numpy as np
import mahotas
from pylab import imshow, show
  
# loading image
img = mahotas.imread('dog_image.png')
    
# filtering the image
img = img[:, :, 0]
     
# setting gaussian filter
gaussian = mahotas.gaussian_filter(img, 15)
  
# setting threshold value
gaussian = (gaussian > gaussian.mean())
  
# making is labelled image
labeled, n = mahotas.label(gaussian)
 
# showing image
print("Labelled Image")
imshow(labelled)
show()
 
# getting haralick features
h_feature = mahotas.features.haralick(labelled)
 
# showing the feature
print("Haralick Features")
imshow(h_feature)
show()


输出 :

示例 2:

Python3

# importing required libraries
import numpy as np
import mahotas
from pylab import imshow, show
  
# loading image
img = mahotas.imread('dog_image.png')
    
# filtering the image
img = img[:, :, 0]
     
# setting gaussian filter
gaussian = mahotas.gaussian_filter(img, 15)
  
# setting threshold value
gaussian = (gaussian > gaussian.mean())
  
# making is labelled image
labeled, n = mahotas.label(gaussian)
 
# showing image
print("Labelled Image")
imshow(labelled)
show()
 
# getting haralick features
h_feature = mahotas.features.haralick(labelled)
 
# showing the feature
print("Haralick Features")
imshow(h_feature)
show()

输出 :