erreur in imshow ?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
KALYAN ACHARJYA
2019-12-1
#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
2019-12-13
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!