OSDN Git Service

git-svn-id: http://svn.sourceforge.jp/svnroot/nyartoolkit/NyARToolkit/trunk@759 7cac0...
[nyartoolkit-and/nyartoolkit-and.git] / lib / src / jp / nyatla / nyartoolkit / core / analyzer / raster / threshold / NyARRasterThresholdAnalyzer_SlidePTile.java
1 package jp.nyatla.nyartoolkit.core.analyzer.raster.threshold;\r
2 \r
3 import jp.nyatla.nyartoolkit.NyARException;\r
4 import jp.nyatla.nyartoolkit.core.analyzer.histogram.*;\r
5 import jp.nyatla.nyartoolkit.core.analyzer.raster.*;\r
6 import jp.nyatla.nyartoolkit.core.raster.INyARRaster;\r
7 import jp.nyatla.nyartoolkit.core.types.NyARHistogram;\r
8 import jp.nyatla.nyartoolkit.core.types.NyARIntRect;\r
9 /**\r
10  * 明点と暗点をPタイル法で検出して、その中央値を閾値とする。\r
11  * \r
12  * \r
13  */\r
14 public class NyARRasterThresholdAnalyzer_SlidePTile implements INyARRasterThresholdAnalyzer\r
15 {\r
16         protected NyARRasterAnalyzer_Histogram _raster_analyzer;\r
17         private NyARHistogramAnalyzer_SlidePTile _sptile;\r
18         private NyARHistogram _histogram;\r
19         public void setVerticalInterval(int i_step)\r
20         {\r
21                 this._raster_analyzer.setVerticalInterval(i_step);\r
22                 return;\r
23         }\r
24         public NyARRasterThresholdAnalyzer_SlidePTile(int i_persentage,int i_raster_format,int i_vertical_interval) throws NyARException\r
25         {\r
26                 assert (0 <= i_persentage && i_persentage <= 50);\r
27                 //初期化\r
28                 if(!initInstance(i_raster_format,i_vertical_interval)){\r
29                         throw new NyARException();\r
30                 }\r
31                 this._sptile=new NyARHistogramAnalyzer_SlidePTile(i_persentage);\r
32                 this._histogram=new NyARHistogram(256);\r
33         }\r
34         protected boolean initInstance(int i_raster_format,int i_vertical_interval) throws NyARException\r
35         {\r
36                 this._raster_analyzer=new NyARRasterAnalyzer_Histogram(i_raster_format,i_vertical_interval);\r
37                 return true;\r
38         }\r
39         public int analyzeRaster(INyARRaster i_input) throws NyARException\r
40         {\r
41                 this._raster_analyzer.analyzeRaster(i_input, this._histogram);\r
42                 return this._sptile.getThreshold(this._histogram);\r
43         }\r
44         public int analyzeRaster(INyARRaster i_input,NyARIntRect i_area) throws NyARException\r
45         {\r
46                 throw new NyARException();\r
47         }\r
48         \r
49 }\r