# Why am i getting two different MSE, while using formula and syntax immse?

조회 수: 2(최근 30일)
IS there any mistake in the formula applied for mean squarred error?
crp_mv_img=imcrop(moving_img, [235, 210, 100, 100]);
crp_fx_img=imcrop(fixed_img, [235, 210, 100, 100]);
mse_1=immse(crp_fx_img,crp_mv_img)
mse_1 = 979.2353
[r,c]=size(crp_fx_img);
mse_2= sum((crp_mv_img-crp_fx_img).^2,"all")/(r*c)
mse_2 = 44.0342
Is mse_2 wrong?

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

### 채택된 답변

DGM 2022년 1월 22일
편집: DGM 2022년 1월 22일
The reason is that the two images are integer-class. The difference and square may result in data truncation.
crp_mv_img = imcrop(moving_img, [235, 210, 100, 100]);
crp_fx_img = imcrop(fixed_img, [235, 210, 100, 100]);
mse_1 = immse(crp_fx_img,crp_mv_img)
mse_1 = 979.2353
[r,c] = size(crp_fx_img);
se = (double(crp_mv_img)-double(crp_fx_img)).^2; % square error
[min(se(:)) max(se(:))] % values are outside of range for uint8
ans = 1×2
0 27225
mse_2 = sum(se,"all")/(r*c)
mse_2 = 979.2353
##### 댓글 수: 1표시숨기기 없음
Samson David Puthenpeedika 2022년 1월 22일
Oh understood! Thankyou so much for the explanation.

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

R2021b

### Community Treasure Hunt

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

Start Hunting!