import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.INyARRaster;\r
import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
+import jp.nyatla.nyartoolkit.core.rasterreader.NyARBufferReader;\r
+import jp.nyatla.nyartoolkit.core.rasterreader.NyARRgbPixelReader_INT1D_X8R8G8B8_32;\r
import jp.nyatla.nyartoolkit.core.types.NyARHistgram;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
import jp.nyatla.nyartoolkit.core.analyzer.histgram.*;\r
*/\r
public class NyARRasterAnalyzer_Histgram\r
{\r
- private ICreateHistgramImpl _histImpl;\r
+ protected ICreateHistgramImpl _histImpl;\r
/**\r
* ヒストグラム解析の縦方向スキップ数。継承クラスはこのライン数づつ\r
* スキップしながらヒストグラム計算を行うこと。\r
\r
public NyARRasterAnalyzer_Histgram(int i_raster_format,int i_vertical_interval) throws NyARException\r
{\r
+ if(!initInstance(i_raster_format,i_vertical_interval)){\r
+ throw new NyARException();\r
+ }\r
+ }\r
+ protected boolean initInstance(int i_raster_format,int i_vertical_interval)\r
+ {\r
switch (i_raster_format) {\r
case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
this._histImpl = new NyARRasterThresholdAnalyzer_Histgram_INT1D_X8R8G8B8_32();\r
break;\r
default:\r
- throw new NyARException();\r
+ return false;\r
}\r
//初期化\r
this._vertical_skip=i_vertical_interval;\r
+ return true;\r
} \r
+ \r
+ \r
public void setVerticalInterval(int i_step)\r
{\r
this._vertical_skip=i_step;\r
*/\r
public class NyARRasterThresholdAnalyzer_SlidePTile implements INyARRasterThresholdAnalyzer\r
{\r
- private NyARRasterAnalyzer_Histgram _raster_analyzer;\r
+ protected NyARRasterAnalyzer_Histgram _raster_analyzer;\r
private NyARHistgramAnalyzer_SlidePTile _sptile;\r
private NyARHistgram _histgram;\r
public void setVerticalInterval(int i_step)\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 NyARHistgramAnalyzer_SlidePTile(i_persentage);\r
this._histgram=new NyARHistgram(256);\r
+ }\r
+ protected boolean initInstance(int i_raster_format,int i_vertical_interval) throws NyARException\r
+ {\r
this._raster_analyzer=new NyARRasterAnalyzer_Histgram(i_raster_format,i_vertical_interval);\r
+ return true;\r
}\r
- \r
public int analyzeRaster(INyARRaster i_input) throws NyARException\r
{\r
this._raster_analyzer.analyzeRaster(i_input, this._histgram);\r
this._is_index_table_enable=i_label_index_enable;\r
return;\r
}\r
- //巡回参照できるように、テーブルを二重化\r
- // 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6\r
- protected final static int[] _getContour_xdir = { 0, 1, 1, 1, 0,-1,-1,-1 , 0, 1, 1, 1, 0,-1,-1};\r
- protected final static int[] _getContour_ydir = {-1,-1, 0, 1, 1, 1, 0,-1 ,-1,-1, 0, 1, 1, 1, 0};\r
/**\r
* i_labelのラベルの、クリップ領域が上辺に接しているx座標を返します。\r
* @param i_index\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
+ assert(i_bin_raster.getBufferReader().isEqualBufferType(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
+ assert(i_gs_raster.getBufferReader().isEqualBufferType(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
protected NyARBufferReader _reader;\r
protected Object _buf;\r
- public INyARBufferReader getBufferReader()\r
- {\r
- return this._reader;\r
- } \r
+ \r
public NyARRaster(NyARIntSize i_size,int i_buf_type) throws NyARException\r
{\r
super(i_size);\r
}\r
this._reader=new NyARBufferReader(this._buf,i_buf_type);\r
return true;\r
+ }\r
+ public INyARBufferReader getBufferReader()\r
+ {\r
+ return this._reader;\r
} \r
}
\ No newline at end of file
\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.labeling.artoolkit.*;\r
\r
/**\r
protected final static int[] _getContour_ydir = {-1,-1, 0, 1, 1, 1, 0,-1 ,-1,-1, 0, 1, 1, 1, 0};\r
public int getContour(NyARBinRaster i_raster,int i_entry_x,int i_entry_y,int i_array_size,int[] o_coord_x,int[] o_coord_y) throws NyARException\r
{\r
+ assert(i_raster.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8));\r
return impl_getContour(i_raster,0,i_entry_x,i_entry_y,i_array_size,o_coord_x,o_coord_y);\r
}\r
/**\r
*/\r
public int getContour(NyARGrayscaleRaster i_raster,int i_th,int i_entry_x,int i_entry_y,int i_array_size,int[] o_coord_x,int[] o_coord_y) throws NyARException\r
{\r
+ assert(i_raster.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
return impl_getContour(i_raster,i_th,i_entry_x,i_entry_y,i_array_size,o_coord_x,o_coord_y);\r
}\r
\r