Remove small chunks of labels in an image

拥有回忆 提交于 2019-12-08 00:25:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!