採用された回答

Image Analyst
Image Analyst 2012 年 10 月 11 日

0 投票

Wouldn't it just go like this
difference = single(image1) - single(image2);
squaredError = difference .^ 2;
meanSquaredError = sum(squaredError(:)) / numel(image1);
rmsError = sqrt(meanSquaredError);
Of course you could compact that all into one line if you want.

5 件のコメント

Mahua Nandy(Pal)
Mahua Nandy(Pal) 2012 年 10 月 14 日
Thanks a lot. Please let me know why single() has to be used?
Image Analyst
Image Analyst 2012 年 10 月 14 日
you need to use single so that you can have negative numbers. If your image is uint8 (0-255 gray levels like most images), then it is UNSIGNED, which means anything that should be negative will be clipped at zero:
smallNumber = uint8(5);
bigNumber = uint8(200);
u8 = smallNumber - bigNumber
s8 = single(smallNumber) - single(bigNumber)
In the command window:
u8 =
0
s8 =
-195
Mahua Nandy(Pal)
Mahua Nandy(Pal) 2012 年 10 月 16 日
Thank you for your lucid clarification.
MAT-Magic
MAT-Magic 2020 年 1 月 18 日
編集済み: Image Analyst 2020 年 1 月 18 日
@Image Analyst, can I use this formula for two vectors having same length?
difference = single(image1) - single(image2);
squaredError = difference .^ 2;
meanSquaredError = sum(squaredError(:)) / numel(image1);
rmsError = sqrt(meanSquaredError);
?
Image Analyst
Image Analyst 2020 年 1 月 18 日
Yes, you can, but I'd use mean() instead of sum to simplify it:
differenceImage = single(image1) - single(image2);
squaredErrorImage = differenceImage .^ 2;
meanSquaredError = mean(squaredErrorImage(:)) % A scalar
rmsError = sqrt(meanSquaredError)
And if they're vectors of the same shape (row or column) then you don't even need the (:).

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

その他の回答 (1 件)

Daniel Shub
Daniel Shub 2012 年 10 月 11 日
編集済み: Daniel Shub 2012 年 10 月 11 日

0 投票

Just to be a little bit difference. If you have the DSP system toolbox you can do
step(dsp.RMS('Dimension', 'all'), x)
where x is your error signal. So in the case of two imagines (image1 and image2)
image1 = randn(128);
image2 = randn(128);
x = image1-image2;

6 件のコメント

Image Analyst
Image Analyst 2012 年 10 月 11 日
Would x = cat(3, image1, image2)?
Daniel Shub
Daniel Shub 2012 年 10 月 11 日
IA what?
Image Analyst
Image Analyst 2012 年 10 月 11 日
He has two images, say image1 and image2 where image1 is the reference image and another image that is the misaligned one. He has attempted to "fix" (register) by aligning it with image1 and that "registered" image is image2. Where would those two images go into your formula?
Daniel Shub
Daniel Shub 2012 年 10 月 11 日
I got it, dsp.RMS calculates the RMS of an n-d signal. So to get the RMS error, x needs to be the error signal. In the case of two images x is the difference between the images.
Ishara Nipuni
Ishara Nipuni 2019 年 1 月 25 日
I calculated the RMS value of my image registration algorithm by using your code. But I can't understand how to do a validation for my registration algorithm with th RMS value. Can you tell me please how can I com to conclusions about the accuracy of my registration algorithm with the use of RMS values?
Ishara Nipuni
Ishara Nipuni 2019 年 1 月 25 日
I calculated the RMS value with getting the same image as image1 and image2. But the value was not zero. But I think that it should be zero. Can you please explain me about it?

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

カテゴリ

ヘルプ センター および File ExchangeGeometric Transformation and Image Registration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by