1 package jp.nyatla.nyartoolkit.core.analyzer.histgram;
\r
3 import jp.nyatla.nyartoolkit.core.types.NyARHistgram;
\r
8 * 明点と暗点を双方向からPタイル法でカウントして、その中央値を閾値とする。
\r
12 public class NyARHistgramAnalyzer_SlidePTile implements INyARHistgramAnalyzer_Threshold
\r
14 private int _persentage;
\r
15 public NyARHistgramAnalyzer_SlidePTile(int i_persentage)
\r
17 assert (0 <= i_persentage && i_persentage <= 50);
\r
19 this._persentage=i_persentage;
\r
21 public int getThreshold(NyARHistgram i_histgram)
\r
24 int n=i_histgram.length;
\r
25 int sum_of_pixel=i_histgram.total_of_data;
\r
26 int[] hist=i_histgram.data;
\r
28 final int th_pixcels = sum_of_pixel * this._persentage / 100;
\r
34 for (th_b = 0; th_b < n-2; th_b++) {
\r
35 th_wk -= hist[th_b];
\r
42 for (th_w = n-1; th_w > 1; th_w--) {
\r
43 th_wk -= hist[th_w];
\r
49 return (th_w + th_b) / 2;
\r