29
!"#$% '()*%++,-$ .,/0 12%-34 ''56787 9%",-#( !"#$%&%' )%*% +%,-.//. 0%-"*1

OpenCV PPM Histogram

Embed Size (px)

Citation preview

Page 1: OpenCV PPM Histogram

!"#$%&'()*%++,-$&.,/0&12%-34&&

''56787&9%",-#(&!"#$%&%'()%*%(

+%,-.//.(0%-"*1(

Page 2: OpenCV PPM Histogram

1:/;,-%&

•  !-/()<:*=)-&

•  '),-/&12%(#/)(&–  >,+/)$(#"&–  ?0(%+0);<&

•  @)*#;&12%(#/)(&–  3)-A);:=)-&–  9"))/0,-$&

–  B(#<,%-/&12%(#/)(+&

Page 3: OpenCV PPM Histogram

1:/;,-%&'),-/&12%(#/)(+&

•  >,+/)$(#"&–  !-/()<:*=)-&–  C)("#;,D#=)-&#-<&EF:#;,D#=)-&

–  >,+/)$(#"&5#/*0,-$&–  >,+/)$(#"&,-&12%-34&

•  ?0(%+0);<&–  !-/()<:*=)-&–  ?G2);)$G&#-<&EH#"2;%&–  ?0(%+0);<&,-&12%-34&

Page 4: OpenCV PPM Histogram

1:/;,-%&@)*#;&12%(#/)(&

•  3)-A);:=)-&–  !-/()<:*=)-&#-<&%H#"2;%&

•  9"))/0,-$&– IA%(#$%&– B#:++,#-&– 5%<,#-&– 9"))/0,-$&,-&12%-34&

Page 5: OpenCV PPM Histogram

3)"2:/%(&4,+,)-&

• &J0#/& /0%& *)"2:/%(& K-..-L&,+&M:+/&#&$(,<&)N&-:"O%(+P&I-G&$,A%-&-:"O%(&.,/0,-&/0#/&$(,<&0#+& #& (#/0%(& ;#($%& -),+%&*)"2)-%-/& #-<& +)& OG& ,/+%;N&$,A%+&:+&;,Q;%&,-N)("#=)-R&O:/&/0,+& $(,<& )N& -:"O%(+& ,+& #;;&/0%&*)"2:/%(&K-..-LP&

• & ?0%& 0:"#-& O(#,-& <,A,<%+& /0%& A,+,)-& +,$-#;& ,-/)&"#-G& *0#--%;+& /0#/&+/(%#"&<,S%(%-/&T,-<+&)N&,-N)("#=)-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& )N& /0%&:-<%(;G,-$& <#/#& )($#-,D%<& ,-/)& #& +%/& )N& 2(%<%V-%<&O,-+P&

Page 8: OpenCV PPM Histogram

>,+/)$(#"&

•  [)(&0,+/)$(#"&<%V-,=)-&.%&*#-&#++:"%&#-&,"#$%&.,/0&M:+/&)-%&,-/%-+,/G&*0#--%;P&

•  >,+/)$(#"Y&

•  J0%(%&$3&,+&/0%&3/0&$(#G&;%A%;&#-<&*3&,+&/0%&-:"O%(&)N&2,H%;+&,-&/0%&,"#$%&0#A,-$&$(#G&;%A%;&$3(

•  E#*0&$(#G&;%A%;&,+&#&O,-R&")(%&O,-+&Y\&")(%&<%/#,;+&Y\&")(%&*)"2:/#=)-#;&*)"2;%H,/GP& &(

Page 9: OpenCV PPM Histogram

>,+/)$(#"&

•  Gray Levels: {0,1, … , 255}

•  Number of Bins: 32

•  Number of intensity levels for each bin: 256 / 32 = 8

6 12 16

200px

620px 370px

Page 10: OpenCV PPM Histogram

>,+/)$(#"&C)("#;,D#=)-&

•  C)("#;,D%<&>,+/)$(#"&X.0G&G):&0#A%&/)&<)&,/]Z&

•  !/&,+&)^%-&<%+,(#O;%&/)&.)(T&.,/0&/0%&0,+/)$(#"&,-&-)("#;,D%<&N)("R&+)&/0#/&,-<,A,<:#;&O,-+&.,;;&/0%-&(%2(%+%-/&/0%&N(#*=)-&)N&/0%&/)/#;&-:"O%(&)N&%A%-/+&#++,$-%<&/)&/0%&%-=(%&0,+/)$(#"P&

•  C)("#;,D%<&0,+/)$(#"&A#;:%+&":+/&O%&(%2(%+%-/%<&OG&_)#/&)(&<):O;%P&1/0%(.,+%&/0%(%&"#G&O%&;)++&)N&,-N)("#=)-&<:%&/)&/(:-*#=)-P&

Page 11: OpenCV PPM Histogram

>,+/)$(#"&EF:#;,D#=)-&

•  3#"%(#+&#-<&,"#$%&+%-+)(+&":+/&:+:#;;G&<%#;&-)/&)-;G&.,/0&/0%&*)-/(#+/&,-&#&+*%-%&O:/&#;+)&.,/0&/0%&,"#$%&+%-+)(+`&%H2)+:(%&/)&/0%&(%+:;=-$&;,$0/&,-&/0#/&+*%-%P&&

•  I^%(&/0%&2,*/:(%&0#+&O%%-&/#T%-R&/0%(% +̀&-)/0,-$&.%&*#-&<)&#O):/&.0#/&/0%&+%-+)(&(%*)(<%<a&0).%A%(R&.%&*#-&+=;;&/#T%&.0#/ +̀&/0%(%&#-<&/(G&/)&%H2#-<&/0%&<G-#",*&(#-$%&)N&/0%&,"#$%P&&

Page 12: OpenCV PPM Histogram

>,+/)$(#"&EF:#;,D#=)-&•  >,+/)$(#"&EF:#;,D#=)-&X.0G&G):&0#A%&/)&<)&,/]Z&

•  ?0%&,"#$%&,+&2))(&O%*#:+%&/0%(% +̀&-)/&":*0&A#(,#=)-&)N&/0%&(#-$%&)N&A#;:%+P&?0,+&,+&%A,<%-/&N()"&/0%&0,+/)$(#"&)N&,/+&,-/%-+,/G&A#;:%+&)-&/0%&(,$0/&

•  >,+/)$(#"&%F:#;,D#=)-&,+&#&"%/0)<&N)(&+/(%/*0,-$&/0,+&(#-$%&):/P&

Page 13: OpenCV PPM Histogram

>,+/)$(#"&EF:#;,D#=)-&•  >,+/)$(#"&%F:#;,D#=)-&,-A);A%+&"#22,-$&)-%&<,+/(,O:=)-&X/0%&

$,A%-&0,+/)$(#"&)N&,-/%-+,/G&A#;:%+Z&/)&#-)/0%(&<,+/(,O:=)-&X#&.,<%(&#-<R&,<%#;;GR&:-,N)("&<,+/(,O:=)-&)N&,-/%-+,/G&A#;:%+ZP&

•  92(%#<&):/&/0%&4WA#;:%+&)N&/0%&)(,$,-#;&<,+/(,O:=)-&#+&%A%-;G&#+&2)++,O;%&,-&/0%&-%.&<,+/(,O:=)-P&

•  b%V-,=)-&)N&*:":;#=A%Y&

Page 14: OpenCV PPM Histogram

>,+/)$(#"&EF:#;,D#=)-&It is possible to use the cumulative distribution function to remap the original distribution as an equally spread distribution simply by looking up each y-value in the original distribution and seeing where it should go in the equalized distribution.

Page 15: OpenCV PPM Histogram

>,+/)$(#"Y&cBd&A+&>94&

•  cBd&,+&-)/&#&$))<&*);)(&+2#*%P&

•  e+,-$&>94&.%&*#-&(%")A%&4&X/0%&A#;:%&)N&,-/%-+,/GZ&#-<&/0%-&.%&*#-&0#-<;%&.,/0&;#($%&A#(,#=)-+&)N&,;;:",-#=)-P&

cBd& >94&

>&

9&

4&

>9&

Page 16: OpenCV PPM Histogram

>,+/)$(#"&5#/*0,-$&

•  >,+/)$(#"+& #(%& :+:#;;G& :+%<& /)& V-<& +,",;#(,/G&O%/.%%-& )OM%*/+& /0#/& *)-/#,-& X)(& -)/Z& /0%& +#"%&*);)(&)(&+/#=+=*+P&

Page 17: OpenCV PPM Histogram

>,+/)$(#"&5#/*0,-$&

•  '%(N)(",-$&#&*)"2#(,+)-&O%/.%%-&O,-+&)N&0,+/)$(#"+&)N&<,S%(%-/&,"#$%+P&

•  >,+/)$(#"+&.,;;&0#A%&/0%&+#"%&-:"O%(&)N&O,-+P&

•  ?0%(%&#(%&+%A%(#;&"%/0)<+&/)&2%(N)("&0,+/)$(#"&"#/*0,-$P&

Page 18: OpenCV PPM Histogram

>,+/)$(#"&5#/*0,-$&

•  3)((%;#=)-Y&

•  30,W9F:#(%Y&

A high score represents a better match than a low score: •  A perfect match is 1; •  A maximal mismatch is –1; •  A value of 0 indicates no correlation (random association).

A low score represents a better match than a high score. •  A perfect match is 0 •  A total mismatch is unbounded (depending on the size of the histogram).

Page 19: OpenCV PPM Histogram

>,+/)$(#"&5#/*0,-$&>,+/)$(#"&5#/*0,-$&

•  !-/%(+%*=)-Y&

•  d0#Q#*0#(GG#Y&

High scores indicate good matches and low scores indicate bad matches. If both histograms are normalized to 1, then: •  A perfect match is 1 •  A total mismatch is 0

Low scores indicate good matches and high scores indicate bad matches. •  A perfect match is 0 •  A total mismatch is a 1.

Page 20: OpenCV PPM Histogram

>,+/)$(#"&,-&12%-34&

•  12%-34&0#+&#&<#/#&/G2%&N)(&(%2(%+%-=-$&0,+/)$(#"+&,-&)-%&)(&"#-G&<,"%-+,)-+P&

•  !/&,+&%F:,22%<&.,/0&#&A#(,%/G&)N&:+%N:;&N:-*=)-+&/)&%#+,;G&2%(N)("&*)"")-&)2%(#=)-+&)-&0,+/)$(#"+P&

•  ?0%&,-/%(-#;&<#/#&)N&/0%&0,+/)$(#"&,+&+/)(%<&,-+,<%&)N&/0%&3A5#/Cb&+/(:*/:(%&

Page 21: OpenCV PPM Histogram

>,+/)$(#"&,-&12%-34&

•  For a uniform histogram, ranges is an array of floating-point value pairs, where the number of value pairs is equal to the number of dimensions.

•  For a non-uniform histogram, the pairs used by the uniform histogram are replaced by arrays containing the values by which the non-uniform bins are separated. If there are N bins, then there will be N + 1 entries in each of these subarrays.

Page 22: OpenCV PPM Histogram

>,+/)$(#"&,-&12%-34&

•  ?0%&/G2%&*#-&O%&%,/0%(&34f>!9?fIccIUR&.0,*0&,+&:+%<&N)(&":;=<,"%-+,)-#;&0,+/)$(#"+&/)&O%&+/)(%<&:+,-$&/0%&<%-+%&":;=<,"%-+,)-#;&"#/(,H&+/(:*/:(%&X,P%PR&3A5#/CbZR&&

•  )(&34f>!9?f&9'Ic9E&,N&/0%&<#/#&,+&/)&O%&+/)(%<&:+,-$&/0%&+2#(+%&"#/(,H&(%2(%+%-/#=)-&X3A92#(+%5#/ZP&

Page 23: OpenCV PPM Histogram

>,+/)$(#"&,-&12%-34&

•  For the i-th channel there are 30 bins in a range from 0 to 180, therefore 6 levels of intensity for each bin.

•  For the j-th channel there are 32 bins in a range from 0 to 255, therefore 8 levels of intensity for each bin.

Page 24: OpenCV PPM Histogram

I**%++,-$&>,+/)$(#"&,-&12%-34&•  E#*0&)N&/0%&N:-*=)-+&)-&/0%&;%^&(%/:(-+&#&_)#=-$W2),-/&-:"O%(&N)(&

/0%&A#;:%&,-&/0%&#22()2(,#/%&O,-P&&

•  !/&,+&#;+)&2)++,O;%&/)&+%/&X)(&$%/Z&0,+/)$(#"&O,-&A#;:%+&.,/0&/0%&N:-*=)-+&/0#/&(%/:(-&#&2),-/%(&/)&#&O,-&X*'5(5'("(#%*6-(7"8,.9:&

Page 25: OpenCV PPM Histogram

>,+/)$(#"&5#/*0,-$&,-&12%-34&

"%/0)<Y&•  34f315'f31ccE@&

•  34f315'f3>!9gc&

•  34f315'f!C?Ec9E3?&

•  34f315'fd>I??I3>IcUUI&

Page 26: OpenCV PPM Histogram

>,+/)$(#"&5#-,2:;#=)-&,-&12%-34&

•  >,+/)$(#"&C)("#;,D#=)-Y&

•  >,+/)$(#"&?0(%+0);<,-$Y&

•  The argument factor is the cutoff for the threshold.

•  The result of thresholding a histogram is that all bins whose value is below the threshold factor are set to 0.

Page 27: OpenCV PPM Histogram

>,+/)$(#"&5#-,2:;#=)-&,-&12%-34&

•  >,+/)$(#"&EF:#;,D#=)-Y&

•  The source and destination must be a single-channel, 8-bit images of the same size.

•  For color images you will have to separate the channels and process them one by one.&

Page 28: OpenCV PPM Histogram

5#+T&,-&12%-34&

•  9)"%&N:-*=)-&,-&12%-34&*#-&/#T%&#+&,-2:/&#&O,-#(G&"#+T&)N&/0%&+#"%&+,D%&)N&/0%&+):(*%P&

•  ?0,+&*#-&O%&:+%<&/)&2()*%++&)(&,-&2#(=*:;#(&*#;*:;#/%&/0%&0,+/)$(#"&N)(&)-;G&)-%&#(%#&)N&/0%&,"#$%P&

Page 29: OpenCV PPM Histogram

•  *Ac%*/#-$;%XhZY&–  1-%&)N&/0%&(%*/#-$;% +̀&A%(=*%+&#-<&/0%&)22)+,/%&(%*/#-$;%&A%(/%H&–  @,-%&*);)(&XcBdZ&)(&O(,$0/-%++&X$(#G+*#;%&,"#$%Z&

–  ?0,*T-%++&)N&;,-%+&/0#/&"#T%&:2&/0%&(%*/#-$;%P&C%$#=A%&A#;:%+&*#:+%&/0%&N:-*=)-&/)&<(#.&#&V;;%<&(%*/#-$;%&X34f[!@@EbZ&

–  ?G2%&)N&/0%&;,-%&

5#+T&,-&12%-34&