Clear Filters
Clear Filters

How to remove the unwanted black region from binary image?

1 view (last 30 days)
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

Answers (0)

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!