Differences between revisions 4 and 6 (spanning 2 versions)
Revision 4 as of 2008-12-08 12:32:36
Size: 769
Editor: anonymous
Comment:
Revision 6 as of 2008-12-08 12:50:12
Size: 1323
Editor: anonymous
Comment:
Deletions are marked like this. Additions are marked like this.
Line 10: Line 10:
The image is characterised by a probability density function (PDF). The PDF ''f'' describes the probability of the occurrence of a discrete grey level ''q'' in the range of grey levels ''Q''. The image is characterised by a '''probability density function''' (PDF). The PDF describes the probability of the occurrence of the discrete grey levels.
Line 12: Line 12:
{{{#!latex
$\sum_{q=0}^Qf_q=1$
}}}
Line 20: Line 17:
The following code calculates the PDF {{{pdf}}} for a byte image in the intervall {{{[0,255]}}} The following code calculates the PDF {{{pdf(q)}}} for a ''byte'' image {{{img}}} in the intervall {{{[0,255]}}}
Line 29: Line 26:
$\sum_{q=0}^{255}f_q=1$ $\sum_{q=0}^{255}pdf(q)=1$
Line 31: Line 28:

The anti-derivative of the PDF is the '''cumulative density function''' (CDF).
{{{#!latex
$cdf(q)=\sum_{q'=0}^{q}pdf(q')$
}}}

The cumulative sum can be calculated using
{{{#!python
cdf=pdf.cumsum()
}}}

{{attachment:landsat_b80_pdfcdf.png}}

The probability of the occurence of grey levels in the interval {{{[a,b]}}} can be calculated from the CDF. In the example shown, the probability of grey levels to occur in the interval {{{[12,25]}}} according to the first peak is 0.068. So roughly 7% of the image pixels lie in this grey level interval.

{{{#!python
cdf[25]-cdf[12]
0.068
}}}

Image statistics

The image is characterised by a probability density function (PDF). The PDF describes the probability of the occurrence of the discrete grey levels.

Example

landsat_b80.png

The following code calculates the PDF pdf(q) for a byte image img in the intervall [0,255]

   1 h=histogram(img,bins=256,range=[0,255],normed=True)
   2 pdf,x=h[0],h[1]

The expression normed=True is used for the normalization of the PDF.

latex error! exitcode was 2 (signal 0), transscript follows:

The anti-derivative of the PDF is the cumulative density function (CDF).

latex error! exitcode was 2 (signal 0), transscript follows:

The cumulative sum can be calculated using

   1 cdf=pdf.cumsum()

landsat_b80_pdfcdf.png

The probability of the occurence of grey levels in the interval [a,b] can be calculated from the CDF. In the example shown, the probability of grey levels to occur in the interval [12,25] according to the first peak is 0.068. So roughly 7% of the image pixels lie in this grey level interval.

   1 cdf[25]-cdf[12]
   2 0.068

LehreWiki: Python/Lesson6 (last edited 2008-12-08 13:15:56 by anonymous)