Not enough input arguments. Error in feature_extract3 (line 3) imdist=rgb2gray(imdist);

8 ビュー (過去 30 日間)
syeda
syeda 2023 年 11 月 22 日
コメント済み: Walter Roberson 2025 年 6 月 24 日
CODE :
function f = feature_extract3( imdist ,scale)
f=[];
imdist=rgb2gray(imdist);
weight=[0.2 0.8];
for i=1:scale
im=imdist;
fun0=@(x)secal(x);
emat=blkproc(im,[8 8] ,fun0);
sort_t = sort(emat(:),'ascend');
len = length(sort_t);
t=sort_t(ceil(len*weight(1)):ceil(len*weight(2)));
mu= mean(t);
ske=skewness(sort_t);
f1=[ mu ske];
im=imdist;
fun1=@(x)fecal(x);
im=double(im);
femat=blkproc(im,[8 8],fun1);
sort_t = sort(femat(:),'ascend');
len = length(sort_t);
t=sort_t(ceil(len*weight(1)):ceil(len*weight(2)));
mu= mean(t);
ske=skewness(sort_t);
f2=[ mu ske];
f=[f f1 f2] ;
imdist = imresize(imdist,0.5);
end
end
Q: This a code for feature extraction from the web, i am getting the error in rgb2gray function
  1 件のコメント
Dyuman Joshi
Dyuman Joshi 2023 年 11 月 22 日
You need to provide (the necessary) input(s) to a function to run it.

サインインしてコメントする。

回答 (1 件)

Abhishek
Abhishek 2025 年 6 月 24 日
Hi @syeda,
Generally, MATLAB throws “not enough input arguments” error when a function is called with fewer input parameters than it requires to execute correctly.
The function ‘feature_extract3’ in the code shared requires two input arguments: ‘imdist’ and ‘scale’. However, only ‘imdist’ argument is being passed, which leads to the error.
To resolve the issue, pass the ‘scale’ parameter along with ‘imdist’ parameter when calling the function.
  2 件のコメント
DGM
DGM 2025 年 6 月 24 日
It's worth noting that the code will also throw an error if the image is not RGB. Inputs to rgb2gray() must be MxNx3. If there's a possibility that the input might already be grayscale, either test for it, or use im2gray() instead.
Walter Roberson
Walter Roberson 2025 年 6 月 24 日
In order for this errror message to appear, imdist must not have been passed to the function -- the function is being called with no parameters at all. For example the function might have been invoked by pressing the green Run button instead of by calling it at the command line passing in appropriate parameters.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangePoint Cloud Processing についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by