Problem with blockprocess while using the block data for feature extraction
古いコメントを表示
Hi,
I am using blockprocess for splitting the image into 10x10 overlapping image blocks and I want to extract features of these blocks but matlab is giving errors. The code for the task is pasted here.
The matlab error is
??? Error using ==> blockproc>userfunDispatcher at 719
There was an error when evaluating the user supplied function FUN. The error message was:
Invalid filename.
Error in ==> blockproc at 214
output_block = userfunDispatcher(fun,input_struct,trim_border);
Error in ==> Main at 57
B= blockproc(g,[4 4],fun);%,'BorderSize',[3 3]); %[M + 2*V, N + 2*H]
Code:
fun=@(block_struct)feature_extraction(block_struct.data);
B= blockproc(g,[4 4],fun,'BorderSize',[3 3]);
Feature extraction function code
function features=feature_extraction(name_images)
[num_im,q]=size(name_images);
features=zeros(num_im,12);
for i=1:num_im
A=imread(name_images(i,:));
A=double(A);
%Normalization of the pixels intensity in [0, N_gray-1]
A=round((N_gray-1)*((A-min(A(:)))/(max(A(:))-min(A(:)))));
features(i,1)=mean2(A);
features(i,2)=std2(A);
features(i,3)=skewness(A(:));
features(i,4)=kurtosis(A(:));
end
kindly guide me what's wrong with it and how may i fix it. is there any alternate way to do it
採用された回答
その他の回答 (1 件)
Image Analyst
2013 年 12 月 22 日
You can't do this:
B=1 blockproc(g,[4 4],fun,'BorderSize',[3 3]);
You have a one, then a space, then a blockproc call. Why is the 1 and a space there????
8 件のコメント
Arslan Ahmad
2013 年 12 月 22 日
Arslan Ahmad
2013 年 12 月 22 日
Image Analyst
2013 年 12 月 22 日
I still don't see the actual error - only line numbers on which it occurs. Can you copy all the red text - ALL of it, not just part of it.
Arslan Ahmad
2013 年 12 月 22 日
Image Analyst
2013 年 12 月 22 日
Wow, you're not making it easy for us to help you, are you? Now it's asking for g. Why don't you just attach the m-file that will reproduce your error? By the way, did you ever look at the demos I uploaded for you? One of them shows how to run blockproc() with a custom defined function like you want to do. Did you try to follow that example???
Arslan Ahmad
2013 年 12 月 22 日
Image Analyst
2013 年 12 月 22 日
This is the error message I got. I'm not sure why you didn't get all this. Maybe it's because you have an old version.
>> blockprocFunDispatcher
Undefined function or variable 'blockprocFunDispatcher'.
>> blockprocFunDispatcher
Undefined function or variable 'blockprocFunDispatcher'.
>> test3
Function BLOCKPROC encountered an error while evaluating the user supplied function handle, FUN.
The cause of the error was:
Error using imread>parse_inputs (line 457)
The filename or url argument must be a string.
Error in imread (line 316)
[filename, fmt_s, extraArgs] = parse_inputs(varargin{:});
Error in test3>feature_extraction (line 13)
A=imread(name_images(i,:));
Error in test3>@(block_struct)feature_extraction(block_struct.data) (line 5)
fun=@(block_struct)feature_extraction(block_struct.data);
Error in blockprocFunDispatcher (line 13)
output_block = fun(block_struct);
Error in blockprocInMemory (line 80)
[ul_output fun_nargout] = blockprocFunDispatcher(fun,block_struct,...
Error in blockproc (line 236)
result_image = blockprocInMemory(source,fun,options);
Error in test3 (line 6)
B= blockproc(g,[4 4],fun,'BorderSize',[3 3]);
Basically the problem looks to be this line:
A=imread(name_images(i,:));
Now, name_images is not a string, but you're trying to treat it as one. I think it's a structure. Once you understand my demo you'll know how to handle the submimage input into your custom function. Why don't you set a breakpoint in the function and step through it to see what's going on? Using the debugger yourself is a lot faster than posting message here.
Arslan Ahmad
2013 年 12 月 22 日
カテゴリ
ヘルプ センター および File Exchange で Blocked Images についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!