2 * PROJECT: NyARToolkit(Extension)
\r
3 * --------------------------------------------------------------------------------
\r
4 * The NyARToolkit is Java edition ARToolKit class library.
\r
5 * Copyright (C)2008-2009 Ryo Iizuka
\r
7 * This program is free software: you can redistribute it and/or modify
\r
8 * it under the terms of the GNU General Public License as published by
\r
9 * the Free Software Foundation, either version 3 of the License, or
\r
10 * (at your option) any later version.
\r
12 * This program is distributed in the hope that it will be useful,
\r
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 * GNU General Public License for more details.
\r
17 * You should have received a copy of the GNU General Public License
\r
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
20 * For further information please contact.
\r
21 * http://nyatla.jp/nyatoolkit/
\r
22 * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
\r
25 package jp.nyatla.nyartoolkit.core.analyzer.histogram;
\r
27 import jp.nyatla.nyartoolkit.core.types.NyARHistogram;
\r
31 * このクラスは、明点・暗点のPTail法で求めた敷居値を合算して、敷居値を計算します。
\r
32 * <p>敷居値決定のアルゴリズム - 明点・暗点両側からPTail法を用いて一定割合の画素を取り除き、その中間値を求めます。</p>
\r
34 public class NyARHistogramAnalyzer_SlidePTile implements INyARHistogramAnalyzer_Threshold
\r
36 private int _persentage;
\r
39 * @param i_persentage
\r
40 * 明点、暗点の両側から取り除く、画素の割合を指定します。0<n<50の範囲で指定します。
\r
42 public NyARHistogramAnalyzer_SlidePTile(int i_persentage)
\r
44 assert (0 <= i_persentage && i_persentage <= 50);
\r
46 this._persentage=i_persentage;
\r
49 * この関数は、SlidePTileを用いて敷居値を1個求めます。敷居値の範囲は、i_histogram引数の範囲と同じです。
\r
51 public int getThreshold(NyARHistogram i_histogram)
\r
54 int n=i_histogram.length;
\r
55 int sum_of_pixel=i_histogram.total_of_data;
\r
56 int[] hist=i_histogram.data;
\r
58 final int th_pixcels = sum_of_pixel * this._persentage / 100;
\r
64 for (th_b = 0; th_b < n-2; th_b++) {
\r
65 th_wk -= hist[th_b];
\r
72 for (th_w = n-1; th_w > 1; th_w--) {
\r
73 th_wk -= hist[th_w];
\r
79 return (th_w + th_b) / 2;
\r