error: invalid call to script

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.

Answers (1)

Voss
Voss on 29 May 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.

Categories

Asked:

on 29 May 2022

Answered:

on 29 May 2022

Community Treasure Hunt

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

Start Hunting!