Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to calculate first and last zero value in histogram?

Subject: How to calculate first and last zero value in histogram?

From: Learner

Date: 28 Jan, 2012 17:33:10

Message: 1 of 4

hello all,
my problem is something like this:
let suppose i have this these histogram pixels for 10 gray level image:

levels - pixels
0 - 0
1 - 0
2 - 2
3 - 0
4 - 6
5 - 7
6 - 0
7 - 8
8 - 0
9 - 0

Now how to know at which level the histogram is starting with some finite value>0, and ending with some finite value>0?
i.e. from above we got first value at gray level=2 & end value at gray level=7.
So how to know that gray value in larger images?

thanks in advance.

Subject: How to calculate first and last zero value in histogram?

From: Learner

Date: 28 Jan, 2012 17:46:10

Message: 2 of 4

i applied this code.. but it is not giving correct answer:

[pixelcount GL]=imhist(grayImage);
>>find(min(pixelcount>0))

ans =

     []

>>find(max(pixelcount>0))

ans =

     1

What to do?

Subject: How to calculate first and last zero value in histogram?

From: Learner

Date: 28 Jan, 2012 17:49:10

Message: 3 of 4

ok ok..i got the answer:

i used this form:
xx=find(pixelcount>0);
min(xx)
max(xx)

Subject: How to calculate first and last zero value in histogram?

From: lav

Date: 28 Jan, 2012 21:06:09

Message: 4 of 4

"Learner" wrote in message <jg1cem$7q2$1@newscl01ah.mathworks.com>...
> ok ok..i got the answer:
>
> i used this form:
> xx=find(pixelcount>0);
> min(xx)
> max(xx)

thank you for providing the answer. now we get to learn this too.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us