问题
I am new in MATLAB also in image processing, I am trying to locate a person frame by frame. so far I have labeled the cropped image (cropped using PeopleDetector) like this, now if I locate exact location of person like i.e. at which pixel location '1' start and end (I know this is not right logic).
All I want is to remove little chunks of white pixels at the right side of the person. I dont know how to do that. please suggest me.
回答1:
You can use bwareaopen:
bwareaopen(A, P)
This removes all objects that have fewer than P
pixels from binary image A
.
回答2:
use regionprops
>> props = regionprops( bwlabel( mask, 4 ), 'Area', 'PixelIdxList' );
>> smallRegions = [props(:).Area] < minNumPixels; % select the small regions
>> mask( [props( smallRegions ).PixelIdxList ] ) = 0; % reset small regions
来源:https://stackoverflow.com/questions/17429545/remove-small-chunks-of-labels-in-an-image