フィルターのクリア

Is this how to calculate Mean Square Error for two images?

37 ビュー (過去 30 日間)
tash7827
tash7827 2015 年 7 月 31 日
コメント済み: DGM 2023 年 7 月 6 日
I have two images: lena (the original) and image_new (the reconstructed image). I would like to calculate the MSE. My code below is not working - any idea why? Matlab keeps saying there are not enough input arguments.
function MSE= MSE(lena, image_new);
[M, N] = size(lena);
error = lena - (image_new);
MSE = sum(sum(error .* error)) / (M * N);
disp(MSE);
end
  2 件のコメント
santosh akon
santosh akon 2018 年 2 月 14 日
err = immse(lena,image_new ); fprintf('\n The mean-squared error is %0.4f\n', err);
Image Analyst
Image Analyst 2018 年 2 月 14 日
You can put this down in the Answer section, along with the identical answer, rather than up here in comments (which are meant to be questions of the poster rather than answers for the poster).

サインインしてコメントする。

採用された回答

elham sa
elham sa 2015 年 7 月 31 日
編集済み: elham sa 2015 年 7 月 31 日
I tried out your code and it works fine.
Are you sure that you are not using the run (F5) to test your function?
Your code works fine with
mse = MSE (img1, img2);
in the command line or within a script.

その他の回答 (3 件)

Image Analyst
Image Analyst 2015 年 7 月 31 日
That code won't give the right answer for uint8 images - the most common type. You need to cast to double before subtraction. But why do that at all when you can just use the built-in function immse():
MSE = immse(lena, image_new);
And you should never use size like that with images. Why not? It will give wrong number of columns if the image is RGB, which it can be even if you think it's not, if you saved the image as a JPG file. See Steve's blog: http://blogs.mathworks.com/steve/2011/03/22/too-much-information-about-the-size-function/
  13 件のコメント
hafidz
hafidz 2023 年 7 月 6 日
cara membandingkan 2 gambar menggunakan MSE apa berdasarkan nilai rgb dari gambar
tersebut?
DGM
DGM 2023 年 7 月 6 日
immse() works just the same for RGB.

サインインしてコメントする。


Sebano
Sebano 2020 年 5 月 19 日
Hi, I am trying to quantify the symmetry of logo images and have used the "immse" (mean square error) function and the "fliplr" from left-to-right code to compare the differences in mean square error (MSE) between the orignial logo and the flipped version of the logo to quantify the symmetry. We are experiencing one issue atm with this approach and I need your help... When analysing logos that are 100% symmetric, the MSE can sometimes be super high when it should be extremely close to zero, since theres no differences between the original and flipped version. What may the issue be here? and any ideas on how to solve it?
  2 件のコメント
Image Analyst
Image Analyst 2020 年 5 月 19 日
You'd have to provide your m-file and the logo that you're having a question about. Use the paper clip icon. You might need to call imregister() to align them first in case the line of symmetry is not right at the middle column.
Sebano
Sebano 2020 年 5 月 20 日
Image Analyst. So here is the codes that I been using and the logo you find in the attachments. As you can see, the MSE is 298 for Starbucks logo, when its super symmetric. Please advise.

サインインしてコメントする。


Claudio Ignacio Fernandez
Claudio Ignacio Fernandez 2020 年 5 月 20 日
Hello Everyone
I'm dealing with similar question.
I'm working with the bands of the Micasense camera, it has 5 bands (red, green, blue, NIR, red-edge). The images are 960x1280 uint16.
I'm registering the images in relation to the lens in the middle of the camera, to keep same distance from all moving images to the fixed one. Using this code I got the best visualization.
imregister(Moving1, Fixed, 'translation', optimizer, metric);
However, is there a way to compute the alignment accuracy or registration error using the RMSE expresed as number of pixels?
I'm using
error1 = immse(Moving1 , Fixed);
and my error is 3.142929187276042e+07 (??). Seems pretty far away from zero but images looks good.
However I would like to :
create a bar plot showing the RMSE and standar deviation between the pair of images.
It is possible to create a map of the error?
  2 件のコメント
Image Analyst
Image Analyst 2020 年 5 月 21 日
Claudio, you could add
imageSize = size(moving1); % Should be [960, 1280, 5] for your Micasense camera image.
numPixels = imageSize(1) * imageSize(2); % Rows * columns for the 3-D, 5 channel image.
RMSE = sqrt(error1) / numPixels;
Claudio Ignacio Fernandez
Claudio Ignacio Fernandez 2020 年 5 月 22 日
Sir.
Thank for your reply.
I will work following this instructions.
Regards.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by