imshow function doesn't work properly in 2020a
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
While running my code, a warning about imshow function comes in the command window like "Attempt to execute SCRIPT imshow as a function:
G:\Matlab 20\toolbox\matlab\images\imshow.m
When I went to this location, I found imshow script.I didn't understand what to do about it. So I did a try by deleting imshow script and made a imshow function in that location. But nothing changed. So,I restored the script.
My code is :
clc
clear all
close all
x=imread('C:\Users\ASUS\Desktop\thesis\demo.png');
imshow(x)
title('Original Grayscale Image');
figure;
x=im2double(x);
d=im2bw(x);
imshow(d)
title('Global Thresholding using MATLAB');
Id =x;
T = 0.5*(min(min(Id))+max(max(Id)));
deltaT = 0.001; % convergence criterion
done = false;
while ~done
g = Id >= T;
Tnext = 0.5*(mean(Id(g)) + mean(Id(~g)));
done = abs(T - Tnext) < deltaT;
T = Tnext;
end
figure;
d=im2bw(x,T);
imshow(d)
title('Global Thresholding using own code');
0 comentarios
Respuestas (1)
Image Analyst
el 21 de En. de 2023
You have shadowed the built-in imshow function with a script of the same name. You should never name scripts or functions after built-in functions. So when your script tries to call (what it thinks is the built-in) imshow, it calls your script instead because that is coming up first in the search path. But because your imshow.m file is a script, not a function, it cannot take any input arguments like you tried to pass it, so it throws the error.
The solution is to take the imshow in your folder and rename it to something else, like imshowTest.m or something.
3 comentarios
DGM
el 22 de En. de 2023
Editada: DGM
el 22 de En. de 2023
The file at that location should be a function file, not a script. The first line in imshow.m should be a function declaration.
function h=imshow(varargin)
%IMSHOW Display image in Handle Graphics figure.
% IMSHOW(I) displays the grayscale image I.
% ... and so on
Just to be sure, make sure there aren't other files shadowing the proper imshow.m file. Check the results using which(). There should only be one result. If there are other user-created files called imshow, rename them to something else.
which imshow -all
If there aren't conflicting files (it doesn't sound like it) and if the imshow.m file in the toolbox does not start with a function declaration, the question is how it got that way. The two possibilities that come to mind are user edits or a bad installation.
Image Analyst
el 22 de En. de 2023
Looking at the file it named:
G:\Matlab 20\toolbox\matlab\images\imshow.m
It looks like you installed MATLAB to your G drive. So it appears that you somehow changed the official version of the file. I think it's best if you uninstall and reinstall MATLAB to get the correct version back on there.
Ver también
Categorías
Más información sobre Environment and Settings 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!