error: invalid call to script

20 visualizaciones (últimos 30 días)
reza arta
reza arta el 29 de Mayo de 2022
Respondida: Voss el 29 de Mayo de 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.

Respuestas (1)

Voss
Voss el 29 de Mayo de 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.

Categorías

Más información sobre Discrete Data Plots 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