different between tiff and jpeg format in calculating MSE and PSNR

2 ビュー (過去 30 日間)
Nik
Nik 2013 年 8 月 26 日
コメント済み: Image Analyst 2013 年 10 月 12 日
I got a code to calculate CR,bpp, MSE and PSNR. I works well for *.jpeg image but not for *.tiff. A message
"Error using -
Integers can only be combined with integers of the same class, or scalar doubles.
Error in sphit (line 38)
D = abs(X-Xc).^2;"
I cannot figure why it happen. The full code is:
X= imread ('lena.tif');
[cr,bpp] = wcompress('c',X,'mask.wtc','spiht','maxloop',12)
Xc = wcompress('u','mask.wtc');
delete('mask.wtc')
colormap(pink(255))
subplot(1,2,1); image(X); title('Original image')
axis square
subplot(1,2,2); image(Xc); title('Compressed image')
axis square
% Finally the MSE and the PSNR are computed.
D = abs(X-Xc).^2;
mse = sum(D(:))/numel(X)
psnr = 10*log10(255*255/mse)

採用された回答

Image Analyst
Image Analyst 2013 年 8 月 26 日
When you see that error, it's fixed by converting the integer variable in the equation to a double.
D = abs(double(X) - Xc) .^ 2;
  2 件のコメント
Nik
Nik 2013 年 8 月 27 日
Thank you Image Analyst.. It WORKS!! :)
Image Analyst
Image Analyst 2013 年 10 月 12 日

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDenoising and Compression についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by