erreur in imshow ?

2 visualizaciones (últimos 30 días)
youb mr
youb mr el 1 de Dic. de 2019
Respondida: Image Analyst el 13 de Dic. de 2019
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)

Respuestas (2)

KALYAN ACHARJYA
KALYAN ACHARJYA el 1 de Dic. de 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)
12.png

Image Analyst
Image Analyst el 13 de Dic. de 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.

Categorías

Más información sobre Images en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by