image - MATLAB ConnectedComponentLabeler does not work in for loop -
i trying set of binary images' eccentricity , solidity values using regionprops
function. obtain label matrix using vision.connectedcomponentlabeler
function.
this code have far:
files = getfiles('images'); ecc = zeros(length(files)); %eccentricity values sol = zeros(length(files)); %solidity values ccl = vision.connectedcomponentlabeler; i=1:length(files) = imread(files{i}); [l num] = step(ccl, i); j=1:num l = changem(l==j, 1, j); %* end stats = regionprops(l, 'all'); ecc(i) = stats.eccentricity; sol(i) = stats.solidity; end
however, when run this, error says indicating line marked *:
error using connectedcomponentlabeler/step
variable-size input signals not supported when outputdatatype property set 'automatic'.'
i not understand matlab talking , not have idea how rid of it.
edit
i have returned bwlabel
function , have no problems now.
the error bit hard understand, can explain means. when use cvst connected components labeller, assumes of images you're going use function are same size. error happens because looks images aren't... hence notion "variable-size input signals".
the "automatic
" property means output data type of images automatic, meaning don't have worry whether data type of output uint8
, uint16
, etc. if want remove error, need manually set output data type of images produced labeller, or outputdatatype
property static. hopefully, images in directory you're reading same data type, override field data type function accepts. available types uint8
, uint16
, uint32
. therefore, assuming images uint8
example, before run loop:
ccl = vision.connectedcomponentlabeler; ccl.outputdatatype = 'uint8';
now run code, , should work. bear in mind input needs logical
have meaningful output.
minor comment
why using cvst connected component labeller when image processing toolbox bwlabel
function works same way? using regionprops
, have access image processing toolbox, should available you. it's simpler use , requires no setup: http://www.mathworks.com/help/images/ref/bwlabel.html
Comments
Post a Comment