erreur in imshow ?

2 次查看(过去 30 天)
youb mr
youb mr 2019-12-1
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)

回答(2 个)

KALYAN ACHARJYA
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)
12.png

Image Analyst
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.

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by