필터 지우기
필터 지우기

I am a begginer. I got error saying "Not enough input arguments." etc

조회 수: 2 (최근 30일)
Yojp21
Yojp21 2023년 4월 26일
댓글: DGM 2023년 4월 26일
I got error and I have no idea how I cna fix it.
COuld you teach me how to fix it, please.
Also, could you check if my codes meet the requirement or not, please??
Assignment details
1. The first function should filter the image with masks to identify the edges and
their orientations.
ˆ Label = 1 for horizontal edges
ˆ Label = 2 for vertical edges
ˆ Label = 3 for 45 degree edges
ˆ Label = 4 for 135 degree (that is -45 degree) edges
ˆ Label = 5 for non-edge pixels, i.e. magnitude of edge is below a given threshold
Tasks 2: Test your code with the two provided images (Image1 and Image2) and display
your results as indexed images with 5 levels if you use the first function and with
4 levels if you use the second function. For each function, compare the results using 2
different (very different) thresholds to decide if the edges are strong enough.
Error message
[EdgeImg, IndexImg] = Function1(InputImg,Threshold);
Error using length
Not enough input arguments.
Error in Function1 (line 28)
IndexImg = len*ones(size(InputImg));
Here is my code
function [EdgeImg, IndexImg] = Function1(InputImg, Threshold)
% Four masks for the entire image
H = [-1 -1 -1; 2 2 2; -1 -1 -1];
V = H';
D45 = [2 -1 -1; -1 2 -1; -1 -1 2];
D135 = [-1 -1 2; -1 2 -1; 2 -1 -1];
% Compute edge strengths and orientations using the four masks
R1 = imfilter(InputImg, H, 'symmetric');
R2 = imfilter(InputImg, V, 'symmetric');
R3 = imfilter(InputImg, D45, 'symmetric');
R4 = imfilter(InputImg, D135, 'symmetric');
% Initial Edgelmg and Indexlmh
EdgeImg = zeros(size(InputImg));
IndexImg = len*ones(size(InputImg));
% Now, loop applied through the pixels at edge using for
for k = 1:size(InputImg,1)
for m = 1:size(InputImg,2)
[R, jip] = max([R1(k,m), R2(k,m), R3(k,m), R4(k,m)]);
if R >= Threshold
EdgeImg(k,m) = R;
IndexImg(k,m) = jip;
else
EdgeImg(k,m) = 0;
IndexImg(k,m) = 5;
end
end
end
figure;
subplot(1,2,1);
imshow(EdgeImg);
title('Edge Image');
subplot(1,2,2);
imshow(IndexImg, []);
title('Index Image');
end
>> InputImg = imread('Image1.jpg');
>> Threshold = 50;
>> [EdgeImg, IndexImg] = Function1(InputImg,Threshold);
Error using length
Not enough input arguments.
Error in Function1 (line 28)
IndexImg = length*ones(size(InputImg));
  댓글 수: 1
DGM
DGM 2023년 4월 26일
length() is a function and requires an input argument.
len is not defined in the given code, but if the given usage of len throws that error, then it must be defined as a function somewhere which internally calls length().
It's not clear why you'd be calling length() at all in this scenario.

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2023년 4월 26일
Try this:
IndexImg = ones(size(InputImg), class(InputImg));

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by