Thursday, March 3, 2011

the hassle and the beauty of "bwboundaries" and "imfill"

I'm not sure why other people would want to fill the inside of a set of boundaries.
But i certainly needed that and needed that quick. Having a tired mind after a day of work, i spent more than i should probing the net for such a nifty script.

The results: NONE'd fit what i want...

So i took sometime to make my own.

function filledIm = fillBoundary(boundaries, imWidth, imHeight)
filledIm(1:imHeight, 1:imWidth)=0;
%% this is just my tired mind style, you could go with zeros(...)

for k=1:length(boundaries),

boundary = boundaries{k};

for bIdx = 1:length(boundary)

filledIm( boundary(bIdx,1),boundary(bIdx,2))=255;

filledIm = imfill(filledIm);


My method is rather slow. If you have a better way(im sure you do), please let me know!!!! Thanks!

No comments:

Post a Comment