I got an error - " Integers can only be combined with integers of the same class, or scalar doubles" .. i have given my code below.. Can you help me out with this error? This is to find MSE value and PSNR value

1 view (last 30 days)
%INPUT OBTAINING
[file path] = uigetfile('*.bmp;''pick an image');
a = imread(file);
figure;
imshow(a);
title('Input Image');
a1 = imnoise(a,'salt & pepper',0.02);
%PREPROCESSING
a=imresize(a,[256 256]);
a1=im2bw(a);
a1=medfilt2(a1);
figure;
imshow(a1);
title('Preprocessed Image')
SquardErrorImage=((a1-a).^2)

Answers (2)

Walter Roberson
Walter Roberson on 1 Dec 2015
SquardErrorImage=((a1-double(a)).^2)

Image Analyst
Image Analyst on 1 Dec 2015
Use the functions immse() and psnr() built in to the Image Processing Toolbox.

Community Treasure Hunt

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

Start Hunting!