private int _persentage;\r
public NyARHistgramAnalyzer_PTile(int i_persentage)\r
{\r
- assert (0 <= i_persentage && i_persentage <= 50);\r
//初期化\r
this._persentage=i_persentage;\r
} \r
{\r
public void doFilter(INyARBufferReader i_input_a,INyARBufferReader i_input_b,INyARBufferReader i_output,NyARIntSize i_size) throws NyARException\r
{\r
+ assert(i_input_a.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert(i_input_b.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert(i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
+ \r
int[] out_buf = (int[]) i_output.getBuffer();\r
int[] in_buf1 = (int[]) i_input_a.getBuffer();\r
int[] in_buf2 = (int[]) i_input_b.getBuffer();\r
{\r
public void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size) throws NyARException\r
{\r
- assert( i_input.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24));\r
+ assert( i_input.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24));\r
+ assert( i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
\r
int[] out_buf = (int[]) i_output.getBuffer();\r
byte[] in_buf = (byte[]) i_input.getBuffer();\r
{\r
public void doFilter(INyARRgbRaster i_input, NyARGrayscaleRaster i_output) throws NyARException\r
{\r
+ \r
INyARBufferReader in_buffer_reader=i_input.getBufferReader(); \r
INyARBufferReader out_buffer_reader=i_output.getBufferReader(); \r
+ assert( out_buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
assert (i_input.getSize().isEqualSize(i_output.getSize()) == true);\r
\r
final int[] out_buf = (int[]) out_buffer_reader.getBuffer();\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
+import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
\r
/**\r
*/\r
public int labeling(NyARBinRaster i_raster,NyARLabelingImage o_destination) throws NyARException\r
{\r
+ assert(i_raster.getBufferReader().getBufferType()==INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8);\r
int label_img_ptr1, label_pixel;\r
int i, j;\r
int n, k; /* work */\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
+import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
import jp.nyatla.nyartoolkit.core.types.stack.NyObjectStack;\r
\r
class RleInfoStack extends NyObjectStack<RleInfoStack.RleInfo>\r
*/\r
public int labeling(NyARBinRaster i_bin_raster, int i_top, int i_bottom,RleLabelFragmentInfoStack o_stack) throws NyARException\r
{\r
+ assert(i_bin_raster.getBufferReader().getBufferType()==INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8);\r
return this.imple_labeling(i_bin_raster,0,i_top,i_bottom,o_stack);\r
}\r
/**\r
*/\r
public int labeling(NyARGrayscaleRaster i_gs_raster,int i_th, int i_top, int i_bottom,RleLabelFragmentInfoStack o_stack) throws NyARException\r
{\r
+ assert(i_gs_raster.getBufferReader().getBufferType()==INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8);\r
return this.imple_labeling(i_gs_raster,i_th,i_top,i_bottom,o_stack);\r
}\r
private int imple_labeling(INyARRaster i_raster,int i_th,int i_top, int i_bottom,RleLabelFragmentInfoStack o_stack) throws NyARException\r
\r
import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
+import jp.nyatla.nyartoolkit.*;\r
\r
public class NyARBinRaster extends NyARRaster_BasicClass\r
{\r
- private INyARBufferReader _buffer_reader;\r
- protected int[] _ref_buf;\r
+ protected Object _buf;\r
+ protected INyARBufferReader _buffer_reader;\r
\r
- public NyARBinRaster(int i_width, int i_height)\r
+ public NyARBinRaster(int i_width, int i_height,int i_raster_type) throws NyARException\r
{\r
super(new NyARIntSize(i_width,i_height));\r
- this._ref_buf = new int[i_height*i_width];\r
- this._buffer_reader=new NyARBufferReader(this._ref_buf,INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8);\r
+ if(!initInstance(this._size,i_raster_type)){\r
+ throw new NyARException();\r
+ }\r
}\r
+ public NyARBinRaster(int i_width, int i_height) throws NyARException\r
+ {\r
+ super(new NyARIntSize(i_width,i_height));\r
+ if(!initInstance(this._size,INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8)){\r
+ throw new NyARException();\r
+ }\r
+ } \r
public INyARBufferReader getBufferReader()\r
{\r
return this._buffer_reader;\r
}\r
+ protected boolean initInstance(NyARIntSize i_size,int i_buf_type)\r
+ {\r
+ switch(i_buf_type)\r
+ {\r
+ case INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8:\r
+ this._buf = new int[i_size.w*i_size.h];\r
+ this._buffer_reader=new NyARBufferReader(this._buf,INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8);\r
+ break;\r
+ default:\r
+ return false;\r
+ }\r
+ this._buffer_reader=new NyARBufferReader(this._buf,i_buf_type);\r
+ return true;\r
+ } \r
}\r
public final class NyARGrayscaleRaster extends NyARRaster_BasicClass\r
{\r
\r
- protected int[] _ref_buf;\r
- private INyARBufferReader _buffer_reader;\r
- \r
- public NyARGrayscaleRaster(int i_width, int i_height)\r
+ protected Object _buf;\r
+ protected INyARBufferReader _buffer_reader;\r
+ public NyARGrayscaleRaster(int i_width, int i_height) throws NyARException\r
{\r
super(new NyARIntSize(i_width,i_height));\r
- this._ref_buf = new int[i_height*i_width];\r
- this._buffer_reader=new NyARBufferReader(this._ref_buf,INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8);\r
+ if(!initInstance(this._size,INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8)){\r
+ throw new NyARException();\r
+ }\r
+ } \r
+ public NyARGrayscaleRaster(int i_width, int i_height,int i_raster_type) throws NyARException\r
+ {\r
+ super(new NyARIntSize(i_width,i_height));\r
+ if(!initInstance(this._size,i_raster_type)){\r
+ throw new NyARException();\r
+ }\r
}\r
public INyARBufferReader getBufferReader()\r
{\r
return this._buffer_reader;\r
}\r
- /**\r
- * 4近傍の画素ベクトルを取得します。\r
- * 0,1,0\r
- * 1,x,1\r
- * 0,1,0\r
- * @param i_raster\r
- * @param x\r
- * @param y\r
- * @param o_v\r
- */\r
- public void getPixelVector4(int x,int y,NyARIntPoint2d o_v)\r
+ protected boolean initInstance(NyARIntSize i_size,int i_buf_type)\r
{\r
- int[] buf=this._ref_buf;\r
- int w=this._size.w;\r
- int idx=w*y+x;\r
- o_v.x=buf[idx+1]-buf[idx-1];\r
- o_v.y=buf[idx+w]-buf[idx-w];\r
+ switch(i_buf_type)\r
+ {\r
+ case INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8:\r
+ this._buf = new int[i_size.w*i_size.h];\r
+ break;\r
+ default:\r
+ return false;\r
+ }\r
+ this._buffer_reader=new NyARBufferReader(this._buf,i_buf_type);\r
+ return true;\r
}\r
- /**\r
- * 8近傍画素ベクトル\r
- * 1,2,1\r
- * 2,x,2\r
- * 1,2,1\r
- * @param i_raster\r
- * @param x\r
- * @param y\r
- * @param o_v\r
- */\r
- public void getPixelVector8(int x,int y,NyARIntPoint2d o_v)\r
- {\r
- int[] buf=this._ref_buf;\r
- NyARIntSize s=this._size;\r
- int idx_0 =s.w*y+x;\r
- int idx_p1=idx_0+s.w;\r
- int idx_m1=idx_0-s.w;\r
- int b=buf[idx_m1-1];\r
- int d=buf[idx_m1+1];\r
- int h=buf[idx_p1-1];\r
- int f=buf[idx_p1+1];\r
- o_v.x=buf[idx_0+1]-buf[idx_0-1]+(d-b+f-h)/2;\r
- o_v.y=buf[idx_p1]-buf[idx_m1]+(f-d+h-b)/2;\r
- }\r
- \r
- public void copyFrom(NyARGrayscaleRaster i_input) throws NyARException\r
- {\r
- int[] out_buf = (int[])this._ref_buf;\r
- int[] in_buf = (int[]) i_input._ref_buf;\r
- System.arraycopy(in_buf,0,out_buf,0,this._size.h*this._size.w);\r
- return;\r
- } \r
- \r
}\r
*/\r
public final class NyARRaster extends NyARRaster_BasicClass\r
{\r
- private NyARBufferReader _reader;\r
+ protected NyARBufferReader _reader;\r
+ protected Object _buf;\r
public INyARBufferReader getBufferReader()\r
{\r
return this._reader;\r
public NyARRaster(NyARIntSize i_size,int i_buf_type) throws NyARException\r
{\r
super(i_size);\r
- init(i_size,i_buf_type);\r
+ if(!initInstance(i_size,i_buf_type)){\r
+ throw new NyARException();\r
+ }\r
return;\r
}\r
- private void init(NyARIntSize i_size,int i_buf_type) throws NyARException\r
+ protected boolean initInstance(NyARIntSize i_size,int i_buf_type)\r
{\r
- Object buf;\r
switch(i_buf_type)\r
{\r
case INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32:\r
- buf=new int[i_size.w*i_size.h];\r
+ this._buf=new int[i_size.w*i_size.h];\r
break;\r
default:\r
- throw new NyARException();\r
+ return false;\r
}\r
- this._reader=new NyARBufferReader(buf,i_buf_type);\r
+ this._reader=new NyARBufferReader(this._buf,i_buf_type);\r
+ return true;\r
} \r
}
\ No newline at end of file
\r
public class NyARRgbRaster extends NyARRgbRaster_BasicClass\r
{\r
- protected Object _ref_buf;\r
-\r
- private INyARRgbPixelReader _reader;\r
- private INyARBufferReader _buffer_reader;\r
- private void init(NyARIntSize i_size,int i_raster_type) throws NyARException\r
- {\r
- switch(i_raster_type)\r
- {\r
- case INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32:\r
- this._ref_buf=new int[i_size.w*i_size.h];\r
- this._reader=new NyARRgbPixelReader_INT1D_X8R8G8B8_32((int[])this._ref_buf,i_size);\r
- break;\r
- default:\r
- throw new NyARException();\r
- }\r
- this._buffer_reader=new NyARBufferReader(this._ref_buf,i_raster_type);\r
- }\r
+ protected Object _buf;\r
+ protected INyARRgbPixelReader _reader;\r
+ protected INyARBufferReader _buffer_reader;\r
public NyARRgbRaster(NyARIntSize i_size,int i_raster_type) throws NyARException\r
{\r
super(i_size);\r
- init(i_size,i_raster_type);\r
+ if(!initInstance(i_size,i_raster_type)){\r
+ throw new NyARException();\r
+ }\r
return;\r
}\r
public INyARRgbPixelReader getRgbPixelReader()\r
public INyARBufferReader getBufferReader()\r
{\r
return this._buffer_reader;\r
+ }\r
+ protected boolean initInstance(NyARIntSize i_size,int i_raster_type)\r
+ {\r
+ switch(i_raster_type)\r
+ {\r
+ case INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32:\r
+ this._buf=new int[i_size.w*i_size.h];\r
+ this._reader=new NyARRgbPixelReader_INT1D_X8R8G8B8_32((int[])this._buf,i_size);\r
+ break;\r
+ default:\r
+ return false;\r
+ }\r
+ this._buffer_reader=new NyARBufferReader(this._buf,i_raster_type);\r
+ return true;\r
} \r
}\r
}\r
public void doFilter(INyARRaster i_input, INyARRaster i_output) throws NyARException\r
{\r
- assert (i_input!=i_output);\r
//ヒストグラムを得る\r
NyARHistgram hist=this._histgram;\r
this._hist_analyzer.analyzeRaster(i_input,hist);\r
\r
public interface INyARRasterFilter_Gs2Bin\r
{\r
- public abstract void doFilter(NyARGrayscaleRaster i_input, NyARBinRaster i_output) throws NyARException;\r
+ public void doFilter(NyARGrayscaleRaster i_input, NyARBinRaster i_output) throws NyARException;\r
\r
}\r
public class NyARRasterFilter_ConstantThrshold implements INyARRasterFilter_Gs2Bin\r
{\r
public int _threshold;\r
- public NyARRasterFilter_ConstantThrshold(int i_initial_threshold) throws NyARException\r
+ public NyARRasterFilter_ConstantThrshold(int i_initial_threshold,int i_in_raster_type,int i_out_raster_type) throws NyARException\r
{\r
+ assert(i_in_raster_type==INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8);\r
+ assert(i_out_raster_type==INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8);\r
//初期化\r
this._threshold=i_initial_threshold;\r
+ \r
}\r
/**\r
* 2値化の閾値を設定する。\r
}\r
public void doFilter(NyARGrayscaleRaster 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
- int[] out_buf = (int[]) out_buffer_reader.getBuffer();\r
- int[] in_buf = (int[]) in_buffer_reader.getBuffer();\r
+ assert(i_input.getBufferReader().getBufferType()==INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8);\r
+ assert(i_output.getBufferReader().getBufferType()==INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8);\r
+ int[] out_buf = (int[]) i_output.getBufferReader().getBuffer();\r
+ int[] in_buf = (int[]) i_input.getBufferReader().getBuffer();\r
NyARIntSize s=i_input.getSize();\r
\r
final int th=this._threshold;\r
*/\r
public class NyARRasterFilter_ARToolkitThreshold implements INyARRasterFilter_RgbToBin\r
{\r
- private int _threshold;\r
+ protected int _threshold;\r
private IdoThFilterImpl _do_threshold_impl;\r
\r
- public NyARRasterFilter_ARToolkitThreshold(int i_threshold,int i_input_raster_type) throws NyARException\r
+ public NyARRasterFilter_ARToolkitThreshold(int i_threshold,int i_in_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
+ if(!initInstance(i_threshold,i_in_raster_type,INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8)){\r
+ throw new NyARException();\r
+ }\r
+ }\r
+ public NyARRasterFilter_ARToolkitThreshold(int i_threshold,int i_in_raster_type,int i_out_raster_type) throws NyARException\r
+ {\r
+ if(!initInstance(i_threshold,i_in_raster_type,i_out_raster_type)){\r
throw new NyARException();\r
}\r
-\r
- \r
}\r
+ protected boolean initInstance(int i_threshold,int i_in_raster_type,int i_out_raster_type)\r
+ {\r
+ switch(i_out_raster_type){\r
+ case INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8:\r
+ switch (i_in_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
+ return false;//サポートしない組み合わせ\r
+ }\r
+ break;\r
+ default:\r
+ return false;//サポートしない組み合わせ\r
+ }\r
+ this._threshold = i_threshold;\r
+ return true;\r
+ } \r
+ \r
/**\r
* 画像を2値化するための閾値。暗点<=th<明点となります。\r
* @param i_threshold\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
public void doThFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size,int i_threshold)\r
{\r
+ assert (i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8));\r
+ \r
int[] out_buf = (int[]) i_output.getBuffer();\r
byte[] in_buf = (byte[]) i_input.getBuffer();\r
\r
{\r
public void doThFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size,int i_threshold)\r
{\r
+ assert (i_input.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8X8_32));\r
+ assert (i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8));\r
+ \r
int[] out_buf = (int[]) i_output.getBuffer();\r
byte[] in_buf = (byte[]) i_input.getBuffer();\r
\r
{\r
public void doThFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size,int i_threshold)\r
{\r
+ assert (i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8));\r
+ \r
int[] out_buf = (int[]) i_output.getBuffer();\r
byte[] in_buf = (byte[]) i_input.getBuffer();\r
\r
{\r
public void doThFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size,int i_threshold)\r
{\r
+ assert (i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8));\r
+ \r
int[] out_buf = (int[]) i_output.getBuffer();\r
int[] in_buf = (int[]) i_input.getBuffer();\r
\r
{\r
public void doThFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size,int i_threshold)\r
{\r
+ assert (i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8));\r
+ \r
int[] out_buf = (int[]) i_output.getBuffer();\r
short[] in_buf = (short[]) i_input.getBuffer();\r
\r
public class NyARRasterFilter_Rgb2Gs_AveAdd implements INyARRasterFilter_RgbToGs\r
{\r
IdoThFilterImpl _do_filter_impl;\r
- public NyARRasterFilter_Rgb2Gs_AveAdd(int i_raster_type) throws NyARException\r
+ public NyARRasterFilter_Rgb2Gs_AveAdd(int i_in_raster_type,int i_out_raster_type) throws NyARException\r
{\r
- switch (i_raster_type) {\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
- this._do_filter_impl=new doThFilterImpl_BYTE1D_B8G8R8_24();\r
- break;\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8X8_32:\r
- this._do_filter_impl=new doThFilterImpl_BYTE1D_B8G8R8X8_32();\r
+ if(!initInstance(i_in_raster_type,i_out_raster_type))\r
+ {\r
+ throw new NyARException();\r
+ }\r
+ }\r
+ public NyARRasterFilter_Rgb2Gs_AveAdd(int i_in_raster_type) throws NyARException\r
+ {\r
+ if(!initInstance(i_in_raster_type,INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8))\r
+ {\r
+ throw new NyARException();\r
+ }\r
+ }\r
+ protected boolean initInstance(int i_in_raster_type,int i_out_raster_type)\r
+ {\r
+ switch(i_out_raster_type){\r
+ case INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8:\r
+ switch (i_in_raster_type){\r
+ case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
+ case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
+ this._do_filter_impl=new doThFilterImpl_BYTE1D_B8G8R8_24();\r
+ break;\r
+ case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8X8_32:\r
+ this._do_filter_impl=new doThFilterImpl_BYTE1D_B8G8R8X8_32();\r
+ break;\r
+ default:\r
+ return false;\r
+ }\r
break;\r
default:\r
- throw new NyARException();\r
+ return false;\r
}\r
+ return true;\r
}\r
+ \r
public void doFilter(INyARRgbRaster i_input, NyARGrayscaleRaster i_output) throws NyARException\r
{\r
INyARBufferReader in_buffer_reader=i_input.getBufferReader(); \r
{\r
public void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size)\r
{\r
+ assert(i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
int[] out_buf = (int[]) i_output.getBuffer();\r
byte[] in_buf = (byte[]) i_input.getBuffer();\r
\r
{\r
public void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size)\r
{\r
+ assert(i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
int[] out_buf = (int[]) i_output.getBuffer();\r
byte[] in_buf = (byte[]) i_input.getBuffer();\r
\r
public class NyARRasterFilter_Rgb2Gs_RgbCube implements INyARRasterFilter_RgbToGs\r
{\r
private IdoFilterImpl _dofilterimpl;\r
- public NyARRasterFilter_Rgb2Gs_RgbCube(int i_raster_type) throws NyARException\r
+ public NyARRasterFilter_Rgb2Gs_RgbCube(int i_in_raster_type) throws NyARException\r
{\r
- switch (i_raster_type) {\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
- this._dofilterimpl=new IdoFilterImpl_BYTE1D_B8G8R8_24();\r
- break;\r
- default:\r
+ if(!initInstance(i_in_raster_type,INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8))\r
+ {\r
throw new NyARException();\r
}\r
}\r
+ public NyARRasterFilter_Rgb2Gs_RgbCube(int i_in_raster_type,int i_out_raster) throws NyARException\r
+ {\r
+ if(!initInstance(i_in_raster_type,i_out_raster))\r
+ {\r
+ throw new NyARException();\r
+ }\r
+ } \r
+ protected boolean initInstance(int i_in_raster_type,int i_out_raster_type)\r
+ {\r
+ switch(i_out_raster_type){\r
+ case INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8:\r
+ switch (i_in_raster_type) {\r
+ case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
+ case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
+ this._dofilterimpl=new IdoFilterImpl_BYTE1D_B8G8R8_24();\r
+ break;\r
+ default:\r
+ return false;\r
+ }\r
+ break;\r
+ default:\r
+ return false;\r
+ }\r
+ return true;\r
+ } \r
+ \r
+ \r
public void doFilter(INyARRgbRaster i_input, NyARGrayscaleRaster i_output) throws NyARException\r
{\r
assert (i_input.getSize().isEqualSize(i_output.getSize()) == true);\r
{\r
assert( i_input.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24)\r
|| i_input.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24));\r
+ assert(i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
\r
int[] out_buf = (int[]) i_output.getBuffer();\r
byte[] in_buf = (byte[]) i_input.getBuffer();\r
public class NyARRasterFilter_Rgb2Gs_YCbCr implements INyARRasterFilter_RgbToGs\r
{\r
private IdoFilterImpl _dofilterimpl;\r
- public NyARRasterFilter_Rgb2Gs_YCbCr(int i_raster_type) throws NyARException\r
+ public NyARRasterFilter_Rgb2Gs_YCbCr(int i_in_raster_type) throws NyARException\r
{\r
- switch (i_raster_type) {\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
- this._dofilterimpl=new IdoFilterImpl_BYTE1D_B8G8R8_24();\r
- break;\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
- default:\r
+ if(!initInstance(i_in_raster_type,INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8))\r
+ {\r
throw new NyARException();\r
}\r
}\r
+ public NyARRasterFilter_Rgb2Gs_YCbCr(int i_in_raster_type,int i_out_raster) throws NyARException\r
+ {\r
+ if(!initInstance(i_in_raster_type,i_out_raster))\r
+ {\r
+ throw new NyARException();\r
+ }\r
+ } \r
+ protected boolean initInstance(int i_in_raster_type,int i_out_raster_type)\r
+ {\r
+ switch(i_out_raster_type){\r
+ case INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8:\r
+ switch (i_in_raster_type) {\r
+ case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
+ this._dofilterimpl=new IdoFilterImpl_BYTE1D_B8G8R8_24();\r
+ break;\r
+ case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
+ default:\r
+ return false;\r
+ }\r
+ break;\r
+ default:\r
+ return false;\r
+ }\r
+ return true;\r
+ } \r
+ \r
public void doFilter(INyARRgbRaster i_input, NyARGrayscaleRaster i_output) throws NyARException\r
{\r
assert (i_input.getSize().isEqualSize(i_output.getSize()) == true);\r
*/\r
public void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size) throws NyARException\r
{\r
- assert( i_input.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24));\r
+ assert( i_input.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24));\r
+ assert(i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
\r
int[] out_buf = (int[]) i_output.getBuffer();\r
byte[] in_buf = (byte[]) i_input.getBuffer();\r
--- /dev/null
+/* \r
+ * PROJECT: NyARToolkit(Extension)\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 modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation, either version 3 of the License, or\r
+ * (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 General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * 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.rasterreader;\r
+\r
+import jp.nyatla.nyartoolkit.core.raster.INyARRaster;\r
+import jp.nyatla.nyartoolkit.core.types.NyARIntPoint2d;\r
+import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
+\r
+public class NyARVectorReader_INT1D_GRAY_8\r
+{\r
+ private int[] _ref_buf;\r
+ private NyARIntSize _ref_size;\r
+ public NyARVectorReader_INT1D_GRAY_8(INyARRaster i_ref_raster)\r
+ {\r
+ assert(i_ref_raster.getBufferReader().getBufferType()==INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8);\r
+ this._ref_buf=(int[])(i_ref_raster.getBufferReader().getBuffer());\r
+ this._ref_size=i_ref_raster.getSize();\r
+ }\r
+ /**\r
+ * 4近傍の画素ベクトルを取得します。\r
+ * 0,1,0\r
+ * 1,x,1\r
+ * 0,1,0\r
+ * @param i_raster\r
+ * @param x\r
+ * @param y\r
+ * @param o_v\r
+ */\r
+ public void getPixelVector4(int x,int y,NyARIntPoint2d o_v)\r
+ {\r
+ int[] buf=this._ref_buf;\r
+ int w=this._ref_size.w;\r
+ int idx=w*y+x;\r
+ o_v.x=buf[idx+1]-buf[idx-1];\r
+ o_v.y=buf[idx+w]-buf[idx-w];\r
+ }\r
+ /**\r
+ * 8近傍画素ベクトル\r
+ * 1,2,1\r
+ * 2,x,2\r
+ * 1,2,1\r
+ * @param i_raster\r
+ * @param x\r
+ * @param y\r
+ * @param o_v\r
+ */\r
+ public void getPixelVector8(int x,int y,NyARIntPoint2d o_v)\r
+ {\r
+ int[] buf=this._ref_buf;\r
+ NyARIntSize s=this._ref_size;\r
+ int idx_0 =s.w*y+x;\r
+ int idx_p1=idx_0+s.w;\r
+ int idx_m1=idx_0-s.w;\r
+ int b=buf[idx_m1-1];\r
+ int d=buf[idx_m1+1];\r
+ int h=buf[idx_p1-1];\r
+ int f=buf[idx_p1+1];\r
+ o_v.x=buf[idx_0+1]-buf[idx_0-1]+(d-b+f-h)/2;\r
+ o_v.y=buf[idx_p1]-buf[idx_m1]+(f-d+h-b)/2;\r
+ } \r
+}
\ No newline at end of file