OSDN Git Service

[tag]NyARToolkit/2.5.1
[nyartoolkit-and/nyartoolkit-and.git] / tags / 2.5.1 / src / jp / nyatla / nyartoolkit / core / analyzer / raster / threshold / NyARRasterThresholdAnalyzer_SlidePTile.java
diff --git a/tags/2.5.1/src/jp/nyatla/nyartoolkit/core/analyzer/raster/threshold/NyARRasterThresholdAnalyzer_SlidePTile.java b/tags/2.5.1/src/jp/nyatla/nyartoolkit/core/analyzer/raster/threshold/NyARRasterThresholdAnalyzer_SlidePTile.java
new file mode 100644 (file)
index 0000000..3c7fb9d
--- /dev/null
@@ -0,0 +1,43 @@
+package jp.nyatla.nyartoolkit.core.analyzer.raster.threshold;\r
+\r
+import jp.nyatla.nyartoolkit.NyARException;\r
+import jp.nyatla.nyartoolkit.core.analyzer.histogram.*;\r
+import jp.nyatla.nyartoolkit.core.analyzer.raster.*;\r
+import jp.nyatla.nyartoolkit.core.raster.INyARRaster;\r
+import jp.nyatla.nyartoolkit.core.types.NyARHistogram;\r
+/**\r
+ * 明点と暗点をPタイル法で検出して、その中央値を閾値とする。\r
+ * \r
+ * \r
+ */\r
+public class NyARRasterThresholdAnalyzer_SlidePTile implements INyARRasterThresholdAnalyzer\r
+{\r
+       protected NyARRasterAnalyzer_Histogram _raster_analyzer;\r
+       private NyARHistogramAnalyzer_SlidePTile _sptile;\r
+       private NyARHistogram _histogram;\r
+       public void setVerticalInterval(int i_step)\r
+       {\r
+               this._raster_analyzer.setVerticalInterval(i_step);\r
+               return;\r
+       }\r
+       public NyARRasterThresholdAnalyzer_SlidePTile(int i_persentage,int i_raster_format,int i_vertical_interval) throws NyARException\r
+       {\r
+               assert (0 <= i_persentage && i_persentage <= 50);\r
+               //初期化\r
+               if(!initInstance(i_raster_format,i_vertical_interval)){\r
+                       throw new NyARException();\r
+               }\r
+               this._sptile=new NyARHistogramAnalyzer_SlidePTile(i_persentage);\r
+               this._histogram=new NyARHistogram(256);\r
+       }\r
+       protected boolean initInstance(int i_raster_format,int i_vertical_interval) throws NyARException\r
+       {\r
+               this._raster_analyzer=new NyARRasterAnalyzer_Histogram(i_raster_format,i_vertical_interval);\r
+               return true;\r
+       }\r
+       public int analyzeRaster(INyARRaster i_input) throws NyARException\r
+       {\r
+               this._raster_analyzer.analyzeRaster(i_input, this._histogram);\r
+               return this._sptile.getThreshold(this._histogram);\r
+       }\r
+}\r