How to normalize GLCMs created for four offsets?
이전 댓글 표시
I am using Matlab 2019b to extract texture features of images using gray level co-occurrence matrix (glcm). I have written the following code to extract rotation invariant features with directions 0, 45, 90, 135. The code creates four glcms and every feature has four values; one per direction.
I = imread('test.jpg')
offsets = [0 1; -1 1;-1 0;-1 -1];
glcm = graycomatrix(I, 'GrayLimits', [], 'Offset',offsets);
stats = graycoprops(glcm);
I want to normalize the glcms then extract each feature from the normalized glcms.
Any help is greatly appreciated.
댓글 수: 2
Image Analyst
2020년 3월 22일
Not sure what you want. Do you just want this
glcm = glcm / sum(glcm(:));
or
glcm = glcm / max(glcm(:));
or
glcm = rescale(glcm, 0, 1);
Mohammad Farhad Aryan
2020년 3월 23일
편집: Mohammad Farhad Aryan
2020년 3월 24일
답변 (2개)
Image Analyst
2020년 3월 24일
Regarding your last comment above . . .It told you it's not integer and it needs integer. So, cast it to integer:
uint8Image = uint8(rescale(rgb2gray(mskRgbImg), 0, 255));
Then pass that into graycomatrix().
See my attached glcm demo.
댓글 수: 3
Mohammad Farhad Aryan
2020년 3월 25일
Image Analyst
2020년 3월 25일
So don't normalize it. Why do you think each should be normalized? If each is normalized independently then how can you compare them?
Mohammad Farhad Aryan
2020년 3월 25일
Hend Abouche
2022년 4월 8일
편집: Image Analyst
2022년 4월 8일
0 개 추천
Hello, I am working on texture features extraction and I want to ask you why you didn't use just the function graycomatrix in a simple way, but you used the offset. Did you do it so you can specify the pixels that you want to calculate their co-occurrence?
댓글 수: 5
Image Analyst
2022년 4월 8일
The default says to only consider the pixel to the right of the moving pixel. Doing that, you'll never learn if there is any pattern in the vertical direction. If you specify more directions then it looks at the values all around the moving pixel, like the average texture in all directions. You only need to do 4 of the 8 because you'll pick up the "unused" pairs once the pixel moved to the line below. For example if you're at column 10, row 5, if you looked at all 8 angles, then when you're on row 5 you'll get the pair of pixels at column 10 at rows 5 and 6 (which is below the pixel). But then when you get to the row below, 6, if you looked all around, you'll get the pair of pixels in rows 5 and 6 again (which is above the current pixel). So there is no need to spend the time to consider the same pair of pixels twice, so you just look at 4 directions, instead of all 8.
Hend Abouche
2022년 4월 9일
Thank u so much for this answer, I really got the idea, and plz I have one more question what is the use of graylimits and Numlevels?, cuz we already convert the rgb image to gray before passing it to graycomatrix function
Image Analyst
2022년 4월 9일
I think it's similar to using different numbers of bins in a histogram. Maybe you want fewer, maybe you want more. Personally I just use as many levels as there are gray levels, like 256 if the image is uint8.
Hend Abouche
2022년 4월 9일
So I did, thank you so much for ur time
nissrine Neyy
2022년 6월 23일
Hi @Image Analyst, i have a question in the same context, what's the difference between using symmetric and not (set it to false or true), i know how it works but in term of results which is better and what does it give or add as an information ?
카테고리
도움말 센터 및 File Exchange에서 Texture Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
