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.
<<
<<
>>
>>
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 个)

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by