erreur in imshow ?
2 views (last 30 days)
Show older comments
Hello everyone. When I try to run my code I have this error in using imshow. I don't know why I'm getting this problem.
This is my code
I = imread('cameraman.tif');
I2 = imresize(rgb2gray(imread('onion.png')),[size(I,1),size(I,2)]);
ImLength = size(I,1);
% Create image large enough to encapsulate both of them
Iend = uint8(zeros(2*ImLength,2*ImLength));
Iend(1:ImLength,1:ImLength) = I; % First image
Iend(ImLength+1:end,1:ImLength) = I2; % Second image
Iend(1:ImLength,ImLength+1:end) = I2; % Second image
Iend(ImLength+1:end,ImLength+1:end) = I; % First image
figure,imshow(Iend)
This is the error message
Attempt to execute SCRIPT image as a function:
C:\Users\hp\Desktop\knn\image.m
Error in images.internal.basicImageDisplay (line 24)
hh = image(cdata, ...
Error in imshow (line 321)
hh = images.internal.basicImageDisplay(fig_handle,ax_handle,...
Error in image (line 26)
figure,imshow(Iend)
0 Comments
Answers (2)
KALYAN ACHARJYA
on 1 Dec 2019
#No Error
I = imread('cameraman.tif');
I2 = imresize(rgb2gray(imread('onion.png')),[size(I,1),size(I,2)]);
ImLength = size(I,1);
% Create image large enough to encapsulate both of them
Iend = uint8(zeros(2*ImLength,2*ImLength));
Iend(1:ImLength,1:ImLength) = I; % First image
Iend(ImLength+1:end,1:ImLength) = I2; % Second image
Iend(1:ImLength,ImLength+1:end) = I2; % Second image
Iend(ImLength+1:end,ImLength+1:end) = I; % First image
figure,imshow(Iend)
Image Analyst
on 13 Dec 2019
This is a classic, perfect example of why it's not good to name your scripts or variables after built-in functions. Since you called your script image.m, it tried to use that (your script) when the imshow() function tries to use the built-in image() function. Rename your script to something else so it doesn't conflict with any built-in function names, like image, or sum, min, max, plot, etc. which are common script names people try to use and which cause problems.
0 Comments
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!