error: invalid call to script

21 vues (au cours des 30 derniers jours)
reza arta
reza arta le 29 Mai 2022
Réponse apportée : Voss le 29 Mai 2022
Hello, i tried writing this code for contrast adjustment homework and it gives me this error:
code:
img=imread('sea.jpg');
figure();
subplot(2,2,1), imshow(img)
subplot(2,2,2), imhist(img)
[m1,m2]= size(img)
final= imadjust(img)
subplot(2,2,3), imshow(final)
subplot(2,2,4), imhist(final)
max=img(1,1);
min=img(1,1);
for i=1:m1
for j=1:m2
if(img(i,j)>max)
max=img(i,j);
end
if (img(i,j)<min)
min= img(i,j);
end
end
end
------------------
The error:
error: invalid call to script /home/oo/imadjust.m
error: called from imadjust sea at line 8 column 6
-------------
why am i getting this error and how can i fix it.

Réponses (1)

Voss
Voss le 29 Mai 2022
You are getting that error because you have a file called imadjust.m (located in /home/oo/), which is a script. Scripts take no input arguments, so trying to execute imadjust(img) (i.e., imadjust with the input img) in your code causes the error.
One way to fix it would be to rename your file imadjust.m to something else, so that when you call imadjust(img) you execute the function from the Image Processing Toolbox imadjust instead of your script.

Catégories

En savoir plus sur Discrete Data Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by