-/* \r
- * PROJECT: NyARToolkit\r
- * --------------------------------------------------------------------------------\r
- * This work is based on the original ARToolKit developed by\r
- * Hirokazu Kato\r
- * Mark Billinghurst\r
- * HITLab, University of Washington, Seattle\r
- * http://www.hitl.washington.edu/artoolkit/\r
- *\r
- * The NyARToolkit is Java edition ARToolKit class library.\r
- * Copyright (C)2008-2009 Ryo Iizuka\r
- *\r
- * This program is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public License\r
- * as published by the Free Software Foundation; either version 3\r
- * of the License, or (at your option) any later version.\r
- * \r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU Lesser General Public License for more details\r
- * \r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- * \r
- * For further information please contact.\r
- * http://nyatla.jp/nyatoolkit/\r
- * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>\r
- * \r
- */\r
package jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.INyARRgbRaster;\r
import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
-import jp.nyatla.nyartoolkit.core.types.*;\r
+import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
+\r
+\r
\r
/**\r
* 定数閾値による2値化をする。\r
*/\r
public class NyARRasterFilter_ARToolkitThreshold implements INyARRasterFilter_RgbToBin\r
{\r
+ private int _threshold;\r
+ private IdoThFilterImpl _do_threshold_impl;\r
+\r
+ public NyARRasterFilter_ARToolkitThreshold(int i_threshold,int i_input_raster_type) throws NyARException\r
+ {\r
+ this._threshold = i_threshold;\r
+ switch (i_input_raster_type) {\r
+ case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
+ case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
+ this._do_threshold_impl=new doThFilterImpl_BUFFERFORMAT_BYTE1D_RGB_24();\r
+ break;\r
+ case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8X8_32:\r
+ this._do_threshold_impl=new doThFilterImpl_BUFFERFORMAT_BYTE1D_B8G8R8X8_32();\r
+ break;\r
+ case INyARBufferReader.BUFFERFORMAT_BYTE1D_X8R8G8B8_32:\r
+ this._do_threshold_impl=new doThFilterImpl_BUFFERFORMAT_BYTE1D_X8R8G8B8_32();\r
+ break;\r
+ case INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32:\r
+ this._do_threshold_impl=new doThFilterImpl_BUFFERFORMAT_INT1D_X8R8G8B8_32();\r
+ break;\r
+ case INyARBufferReader.BUFFERFORMAT_WORD1D_R5G6B5_16LE:\r
+ this._do_threshold_impl=new doThFilterImpl_BUFFERFORMAT_WORD1D_R5G6B5_16LE();\r
+ break;\r
+ default:\r
+ throw new NyARException();\r
+ }\r
+\r
+ \r
+ }\r
+ /**\r
+ * 画像を2値化するための閾値。暗点<=th<明点となります。\r
+ * @param i_threshold\r
+ */\r
+ public void setThreshold(int i_threshold)\r
+ {\r
+ this._threshold = i_threshold;\r
+ }\r
+\r
+ public void doFilter(INyARRgbRaster i_input, NyARBinRaster i_output) throws NyARException\r
+ {\r
+ INyARBufferReader in_buffer_reader=i_input.getBufferReader(); \r
+ INyARBufferReader out_buffer_reader=i_output.getBufferReader();\r
+\r
+ assert (out_buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8));\r
+ assert (i_input.getSize().isEqualSize(i_output.getSize()) == true);\r
+ this._do_threshold_impl.doThFilter(in_buffer_reader,out_buffer_reader,i_output.getSize(), this._threshold);\r
+ return;\r
+ }\r
+ /*\r
+ * ここから各ラスタ用のフィルタ実装\r
+ */\r
interface IdoThFilterImpl\r
{\r
public void doThFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size,int i_threshold);\r
}\r
} \r
} \r
- \r
- \r
- \r
- \r
-\r
- \r
- \r
- \r
- \r
- private int _threshold;\r
- private IdoThFilterImpl _do_threshold_impl;\r
-\r
- public NyARRasterFilter_ARToolkitThreshold(int i_threshold,int i_input_raster_type) throws NyARException\r
- {\r
- this._threshold = i_threshold;\r
- switch (i_input_raster_type) {\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
- this._do_threshold_impl=new doThFilterImpl_BUFFERFORMAT_BYTE1D_RGB_24();\r
- break;\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8X8_32:\r
- this._do_threshold_impl=new doThFilterImpl_BUFFERFORMAT_BYTE1D_B8G8R8X8_32();\r
- break;\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_X8R8G8B8_32:\r
- this._do_threshold_impl=new doThFilterImpl_BUFFERFORMAT_BYTE1D_X8R8G8B8_32();\r
- break;\r
- case INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32:\r
- this._do_threshold_impl=new doThFilterImpl_BUFFERFORMAT_INT1D_X8R8G8B8_32();\r
- break;\r
- case INyARBufferReader.BUFFERFORMAT_WORD1D_R5G6B5_16LE:\r
- this._do_threshold_impl=new doThFilterImpl_BUFFERFORMAT_WORD1D_R5G6B5_16LE();\r
- break;\r
- default:\r
- throw new NyARException();\r
- }\r
-\r
- \r
- }\r
- public void setThreshold(int i_threshold)\r
- {\r
- this._threshold = i_threshold;\r
- }\r
-\r
- public void doFilter(INyARRgbRaster i_input, NyARBinRaster i_output) throws NyARException\r
- {\r
- INyARBufferReader in_buffer_reader=i_input.getBufferReader(); \r
- INyARBufferReader out_buffer_reader=i_output.getBufferReader();\r
-\r
- assert (out_buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8));\r
- assert (i_input.getSize().isEqualSize(i_output.getSize()) == true);\r
- this._do_threshold_impl.doThFilter(in_buffer_reader,out_buffer_reader,i_output.getSize(), this._threshold);\r
- return;\r
- }\r
-\r
}\r