erreur in imshow ?

5 visualizzazioni (ultimi 30 giorni)
youb mr
youb mr il 1 Dic 2019
Risposto: Image Analyst il 13 Dic 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)

Risposte (2)

KALYAN ACHARJYA
KALYAN ACHARJYA il 1 Dic 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 il 13 Dic 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.

Categorie

Scopri di più su Images in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by