How to solve error "Error using bwmorph"

I want to doing a feature extraction steps for multiple images, i have this function:
% this function is supposed to extract features from the input image
function [features]=feature_extraction(I)
if length(size(I))>2 % checking if rgb image;
I=im2bw(I,graythresh(I));
end
I=bwmorph(I,'skel',inf);
I=discourser(I);
row=size(I,1);
column=size(I,2); ... and so on.
And I call it in another script.
files = dir('*.png');
for i = 1:numel(files)
I = files(i).name;
[getfeature] = feature_extraction(I);
end

5 件のコメント

Walter Roberson
Walter Roberson 2015 年 8 月 4 日
You omitted the error message.
ana ain
ana ain 2015 年 8 月 4 日
編集済み: ana ain 2015 年 8 月 4 日
I sorry, the following is the error message:
Error using bwmorph Expected input number 1, BW, to be one of these types:
double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64, logical
Instead its type was char.
Error in bwmorph (line 91) validateattributes(bwin,{'numeric' 'logical'},{'real' 'nonsparse' '2d'}, ...
Error in feature_extraction (line 13) I=bwmorph(I,'skel',inf);
Walter Roberson
Walter Roberson 2015 年 8 月 4 日
Yes, to be expected when you pass in the name of the file instead of the content of the file.
ana ain
ana ain 2015 年 8 月 6 日
could you please explain using some example? Thank you :)
Walter Roberson
Walter Roberson 2015 年 8 月 6 日
I understand that. What I'm saying is that if you put the responses into into a file and then run
myexe.exe < c:\temp\inputs.txt
in the command shell and then, assuming that works,
system('myexe.exe < c:\temp\inputs.txt')
does it work?

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

 採用された回答

Walter Roberson
Walter Roberson 2015 年 8 月 4 日

0 投票

You are passing the file name into the function. The name of the file does not have more than 2 dimensions so you do not use im2bw(). You are passing the name of the file to bwmorph. bwmorph is not defined for character strings.
Have you considered the possibility of reading the file content at some point?

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by