How to extract GLCM matrix from cloud images?
1 view (last 30 days)
Show older comments
thomasB on 10 Dec 2013
Commented: khadija portu on 31 Mar 2023
Dear all, I have a question regarding textural analysis of sky images. To implement a cloud classification algorithm I need to extract several statistical & textural features from the clouds present in the image. For starters I use the bwareaopen(binIM,1000)on my already formed binary image including the clouds(value :1) and sky(value :0) & regionprops(L, 'PixelIdxList','Centroid','BoundingBox') function to extract the different properties touching pixels = clouds/boundingbox/centroids in the image which are labeled 1:n
However the clouds in my image are of irregular shape(not rectangular) en via the linear indexing I can extract several statistical features regarding the grey-value(R,G,B) images. The construction of a GLCM matrix however is not possible. Due to the irregular shape and via the linear indexing the pair-wise comparison of grayvalue pixels isn't carried through. (matlab views B1(idx), which is my blue color component for a cloud, as a vector and not a matrix) I was thinking of using the bounding box to construct a GLCM of my cloud and putting all the non-cloud pixels in the bounding box to Nan so these wont be used in the feature calculation. However I have no idea of how to construct such a matrix which surrounds my cloud mere from the linear indexing, can someone help me with that?
Thanks in advance.
NumLevels = 64; % reduce number of grey levels --> 6 bit offsets = [0 1; -1 1; -1 0; -1 -1]; % 0°,45°,90°,135° angle (diagonals) glcm = zeros(NumLevels,NumLevels,4,n); [glcm_avg, glcm_norm] = deal(zeros(NumLevels,NumLevels,n));
for k = 1:n idx = s(k).PixelIdxList; Bcloud = mat2gray(B1(idx)); Bglcm = gray2ind(Bcloud,NumLevels); %% which is a vector - matrix of cloud shape glcm(:,:,:,k) = graycomatrix(Bglcm,'NumLevels', NumLevels, 'Offset', offsets,'GrayLimits', [1 64]); glcm_avg(:,:,k) = (glcm(:,:,1,k) + glcm(:,:,2,k) + glcm(:,:,3,k) + glcm(:,:,4,k)) / 4 ; glcm_norm(:,:,k) = glcm_avg(:,:,k)/(sum(sum(glcm_avg(:,:,k)))); %normalize glcm matrix end
The result gives a zero matrix in all cases for the glcm_norm
Find more on Texture Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!