计算图像中特定点的GLCM的方法 [英] the method of calculate the GLCM of a specific point in a image

查看:199
本文介绍了计算图像中特定点的GLCM的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

众所周知,GLCM(灰度共生矩阵)描述了图像的纹理特征。但通常情况下,在OpenCV中计算GLCM,matlab经常针对图片。但是现在我只想获得图像中每个点的GLCM值,但是如何得到它?

As we know, GLCM (Grey Level Co-occurrence Matrix) describes the texture characteristics of images. But in usual, the calculation of GLCM in OpenCV, matlab often aim on a picture. But now I just want to get GLCM value of every single point inside the image, but how to get it?

推荐答案

如果我正确理解你的问题,然后你可以将你感兴趣的区域之外的像素设置为NaN - 在计算GLCM时,MATLAB会忽略这些像素。

If I understand your problem correctly, then perhaps you can just set the pixels outside your region of interest to NaN - these pixels are ignored by MATLAB when calculating the GLCM.

例如:

>> im = eye(7)
im =
     1     0     0     0     0     0     0
     0     1     0     0     0     0     0
     0     0     1     0     0     0     0
     0     0     0     1     0     0     0
     0     0     0     0     1     0     0
     0     0     0     0     0     1     0
     0     0     0     0     0     0     1
>> graycomatrix(im)
ans =
    30     0     0     0     0     0     0     6
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     6     0     0     0     0     0     0     0
>> im([1:10,13:16,21:24,28:29,34:37,41:49]) = NaN % Remove pixels outside ROI
im =
   NaN   NaN   NaN   NaN   NaN   NaN   NaN
   NaN   NaN   NaN   NaN     0   NaN   NaN
   NaN   NaN     1   NaN     0     0   NaN
   NaN     0     0     1     0     0   NaN
   NaN     0     0     0     1     0   NaN
   NaN   NaN     0     0   NaN   NaN   NaN
   NaN   NaN   NaN   NaN   NaN   NaN   NaN
>> warning('off', 'Images:graycomatrix:scaledImageContainsNan')
>> graycomatrix(im)
ans =
     6     0     0     0     0     0     0     2
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     2     0     0     0     0     0     0     0
>> warning('on', 'Images:graycomatrix:scaledImageContainsNan')

这样做你需要的吗?

这篇关于计算图像中特定点的GLCM的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆