How to get Object to Background pixel ratio OBR) of an image

I am new in matlab,I am confused how to get value Object to background pixel ratio(OBR) of an image.This is my code.Please Help me.Thank you..
Image = imread('1.jpg');
BW = im2bw(Image);
[labeled,num] = bwlabel(BW,4);
nBlack = sum(BW(:));
nWhite = numel(BW) - nBlack;
OBR=num/nBlack;

Answers (0)

Tags

No tags entered yet.

Asked:

on 16 Apr 2013

Community Treasure Hunt

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

Start Hunting!