Can anyone help me to find "Maximal Correlation Coefficient"?(Square root of second largest eigenvalue) This is the 14th feature of the Harlick Texture Features. I just need to calculate it out of those features. Can i get a piece of code for it?
4 views (last 30 days)
Show older comments
a=rgb2gray(imread('IM_0524-Frame1.jpg'));
a=im2double(a);
counter=1;
[row,col]=size(a);
for i =2:1:2
for j=2:1:2
temp= a(i-1:i+1, j-1:j+1);
offset1 = [0 0];
offset2 = [1 1];
offset3 = [0 1];
offset4 = [-1 1];
%glcm1=graycomatrix(temp,'numlevels',256,'offset',[0 1]);
glcm1 = graycomatrix(temp,'offset',offset1);
% Need to calculate Maximal correlation coefficient for glcm1.
end;
end;
4 Comments
Bryan Redd
on 5 Nov 2019
Did you ever figure this out? I am also looking for the code to calculate the fourteenth feature. I would like to check my work.
Walter Roberson
on 5 Nov 2019
Is it "second largest" according to absolute value? What if there is a tie?
temp = eigs(A, [], 2, 'largestabs');
result = sqrt(temp);
Answers (1)
Pawel Badura
on 30 Sep 2022
Edited: Pawel Badura
on 30 Sep 2022
If you use dr Pierce's PORTS package (https://www.mathworks.com/matlabcentral/fileexchange/55587-ports-3d-image-texture-metric-calculation-package?s_tid=prof_contriblnk), just update the compute_GTSDM_metrics.m script by adding the following code below line 258:
% (14) Maximal Correlation Coefficient
%%% I don't think we use it, so I'll only code it up if needed.
%% ADDED BY PB: 2022-09-30 %%%
Q = zeros(size(p));
p_x0 = max(p_x, 1e-10); % just to make sure there's no division-by-0 later
p_y0 = max(p_y, 1e-10); % just to make sure there's no division-by-0 later
for i=1:N_g
for j=1:N_g
Q(i,j) = sum((p(i,:) .* p(j,:)) ./ (p_x0(i) * p_y0'));
end
end
MCC = eigs(Q, 2);
metrics_vect(14) = sqrt(MCC(2));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!