Borrar filtros
Borrar filtros

How to remove the unwanted black region from binary image?

1 visualización (últimos 30 días)
Usman
Usman el 25 de Nov. de 2015
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

Respuestas (0)

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by