Error - Error using im2double

2 views (last 30 days)
Sara Kadam
Sara Kadam on 25 Apr 2023
Edited: Walter Roberson on 25 Apr 2023
I implemented the following code for non-overlapping patch and I'm getting this error. What does this mean?
Thank you.
*Code -*
YourImage = im2double('house.jpg');
[m,n] = size(YourImage);
Blocks = cell(m/16,n/16);
counti = 0;
for i = 1:16:m-15
counti = counti + 1;
countj = 0;
for j = 1:16:n-15
countj = countj + 1;
Blocks{counti,countj} = YourImage(i:i+15,j:j+15);
end
end
*Error Message -*
Error using im2double
Expected input number 1, Image, to be one of these types:
double, logical, uint8, uint16, int16, single
  1 Comment
Stephen23
Stephen23 on 25 Apr 2023
Edited: Stephen23 on 25 Apr 2023
"What does this mean?"
The IM2DOUBLE documentation states that its first input must be an "Input image, specified as a numeric scalar, vector, matrix, or multidimensional array." Instead of providing a numeric image, you have called IM2DOUBLE with some text.
I do not see anything in the IM2DOUBLE documentation to suggest that it accepts text as its first input.
If you are trying to import an image from a file try using an image importing function, e.g. IMREAD:

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 25 Apr 2023
Your code does not use im2double. And you did not post the entire error message (all the red text). I know because the line number and actual line of code is not included in what you post, and they are in the actual error message. We can't see what you really did So...

Categories

Find more on Convert Image Type in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!