How to remove the unwanted black region from binary image?
1 回表示 (過去 30 日間)
古いコメントを表示
I have converted the images into binary image then calculate its black and white pixels. after calculation i have calculate the ratio, but problem is ratio is not coming what i want. I think there is an extra black region image therefore it creates problem. I have to used the results to declare an eye is open or closed. If R is greater than 20% than eye is open state else close. Can anyone one help me to figure out where is the problem and removes the unwanted black region as shown in attached images.
<<
<<
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/152159/image.png)
>>
>>
I=imread('op.jpg');
thres_level=graythresh(I); % find the threshold level of image
bw=im2bw(I,thres_level); % converts an image into binary
figure, imshow(bw);
totnumpix=numel(bw); % calculate total no of pixels in image
nblack_open=sum(bw(:)); % calculate the black pixels in image;
nwhite_open=totnumpix-nblack_open; %calculate white pixels in image;
R=(nblack_open/(nblack_open+nwhite_open))*100; %calculate ratio of black pixels
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!