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 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!