From: Ish Khan on 5 May 2010 00:52 Hi, I am trying to find the area of a binary image, when I use the bwarea command I am given the area for the 0 (on pixel) only, i am looking for to find the 1 (off pixel), how can i do that?
From: Walter Roberson on 5 May 2010 02:48 Ish Khan wrote: > Hi, I am trying to find the area of a binary image, when I use the > bwarea command I am given the area for the 0 (on pixel) only, i am > looking for to find the 1 (off pixel), > how can i do that? The convention is that 0 pixels are off and 1 pixels are on. This corresponds to a brightness of 0 intensity meaning "black" and thus "no information", and a brightness of 1 intensity meaning "white" and thus "full information". If you have a binary image in which the meaning of 0 and 1 are reversed from this convention, then it would probably be better to go back and re-code so that you use the convention, as otherwise people who look at your code knowing the convention are going to misunderstand it. If the code is just for yourself, perhaps for experimentation, then instead of passing in your current binary image, pass in the logical negation of it. For example, instead of bwlabel(Q), you would use bwlabel(~Q)
From: Ish Khan on 5 May 2010 03:20 Walter Roberson <roberson(a)hushmail.com> wrote in message <Qw8En.7$8_2.0(a)newsfe17.iad>... > Ish Khan wrote: > > Hi, I am trying to find the area of a binary image, when I use the > > bwarea command I am given the area for the 0 (on pixel) only, i am > > looking for to find the 1 (off pixel), > > how can i do that? > > The convention is that 0 pixels are off and 1 pixels are on. This > corresponds to a brightness of 0 intensity meaning "black" and thus "no > information", and a brightness of 1 intensity meaning "white" and thus > "full information". > > If you have a binary image in which the meaning of 0 and 1 are reversed > from this convention, then it would probably be better to go back and > re-code so that you use the convention, as otherwise people who look at > your code knowing the convention are going to misunderstand it. > > If the code is just for yourself, perhaps for experimentation, then > instead of passing in your current binary image, pass in the logical > negation of it. For example, instead of bwlabel(Q), you would use > bwlabel(~Q) Thank you very much Walter for your reply, really appreciate it. Sorry for the confusion too, mine is also set up the convention way, being very new to matlab programming, I just become confused about 1 and 0. any way, I actually want the area of the 0 one, which is the black part, but I am only getting the area of the 1 part, that is white. what should i do to get the area of the black part? Thank you for everything!
From: Walter Roberson on 5 May 2010 03:26 Ish Khan wrote: > mine is also set up the convention way, being > very new to matlab programming, I just become confused about 1 and 0. > any way, I actually want the area of the 0 one, which is the black part, > but I am only getting the area of the 1 part, that is white. what should > i do to get the area of the black part? The fastest way: numel() of the binary array (or is it numels()? I keep forgetting) and subtract the area of the white part from that. Anything that isn't white is black...
From: ImageAnalyst on 5 May 2010 06:13 I never heard of bwarea(). Try this: numberOfBlackPixels = sum(~binaryImage(:))
|
Pages: 1 Prev: Plotting of the powe spectra of digital sequences Next: Simulink help required. plz |