Info

This question is closed. Reopen it to edit or answer.

How to remove this error??

1 view (last 30 days)
Sana khan
Sana khan on 15 May 2017
Closed: MATLAB Answer Bot on 20 Aug 2021
here is my code
function [B C] image_comparison1 (H,D)
H=imread('n.jpg');
H=double(rgb2gray(H));
[m,n] = size(H);
D=imread('9.jpg');
D=double(rgb2gray(D));
[r,c]=size(D);
if m<r
B = zeros(r,c);
B=H;
else if r<m
C = zeros(m,n);
C=D;
end
end
  4 Comments
Jan
Jan on 15 May 2017
What is the purpose of the code?
B = zeros(r,c); % Useless, is overwritten directly:
B=H;
If m==r the code fails, because B and C are not created.
Cam Salzberger
Cam Salzberger on 15 May 2017
Also, depending on what you're trying to do, you may want to consider im2double rather then just casting to double. At least if you will be doing image processing functionality on the image afterwards.

Answers (0)

Community Treasure Hunt

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

Start Hunting!