#acl AdminGroup:read,write,revert,delete EditorGroup:read,write,revert,delete All:read #format wiki #language en #pragma section-numbers off = 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 == {{attachment:landsat_b80.png}} The following code calculates the PDF {{{pdf(q)}}} for a ''byte'' image {{{img}}} in the intervall {{{[0,255]}}} {{{#!python h=histogram(img,bins=256,range=[0,255],normed=True) pdf,x=h[0],h[1] }}} The expression {{{normed=True}}} is used for the normalization of the PDF. {{{#!latex $\sum_{q=0}^{255}pdf(q)=1$ }}} 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 are in this grey level interval. {{{#!python cdf[25]-cdf[12] 0.068 }}}