Calculating mean square difference (MSD) of two matrices

조회 수: 32 (최근 30일)
Jimmy Neutron
Jimmy Neutron 2021년 11월 25일
편집: DGM 2021년 11월 27일
I would like to calculate the MSD of two matrices, but I cannot figure what MSD actually is. From my understanding, it is like this:
Im = [0 252 204;
221 135 58;
156 122 127]
Im2 = [169 250 237;
186 196 148;
227 148 4]
F2 = sum(sum(mean(Im2-Im).^2))

채택된 답변

Chunru
Chunru 2021년 11월 25일
Im = [0 252 204;
221 135 58;
156 122 127]
Im = 3×3
0 252 204 221 135 58 156 122 127
Im2 = [169 250 237;
186 196 148;
227 148 4]
Im2 = 3×3
169 250 237 186 196 148 227 148 4
F2 = sum(sum(mean(Im2-Im).^2))
F2 = 5.4722e+03
% Mean Squared Difference
% mean diff squared all elements
F = mean((Im - Im2).^2, 'all')
F = 7.0607e+03
  댓글 수: 3
Chunru
Chunru 2021년 11월 26일
'all' means to sum all elements of the array. sum(sum(mean(Im2-Im).^2)) is to compute the difference (Im2-Im), then find its mean, then square, then sum up all elements.
DGM
DGM 2021년 11월 27일
편집: DGM 2021년 11월 27일
If you have IPT, why not just use immse()?
Im = [0 252 204;
221 135 58;
156 122 127];
Im2 = [169 250 237;
186 196 148;
227 148 4];
% you could do all this
F = mean((Im - Im2).^2,'all')
F = 7.0607e+03
% or you could just do this
F = immse(Im,Im2)
F = 7.0607e+03

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by