error: invalid call to script

조회 수: 21 (최근 30일)
reza arta
reza arta 2022년 5월 29일
답변: Voss 2022년 5월 29일
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.

답변 (1개)

Voss
Voss 2022년 5월 29일
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.

카테고리

Help CenterFile Exchange에서 Discrete Data Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by