* <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>\r
* \r
*/\r
-package jp.nyatla.nyartoolkit.core.analyzer.histgram;\r
+package jp.nyatla.nyartoolkit.core.analyzer.histogram;\r
\r
\r
import jp.nyatla.nyartoolkit.core.types.*;\r
* Pタイル法による閾値検出\r
* \r
*/\r
-public class NyARHistgramAnalyzer_PTile\r
+public class NyARHistogramAnalyzer_PTile\r
{\r
private int _persentage;\r
- public NyARHistgramAnalyzer_PTile(int i_persentage)\r
+ public NyARHistogramAnalyzer_PTile(int i_persentage)\r
{\r
//初期化\r
this._persentage=i_persentage;\r
} \r
- public int getThreshold(NyARHistgram i_histgram)\r
+ public int getThreshold(NyARHistogram i_histogram)\r
{\r
// 閾値ピクセル数確定\r
- int th_pixcels = i_histgram.total_of_data * this._persentage / 100;\r
+ int th_pixcels = i_histogram.total_of_data * this._persentage / 100;\r
\r
// 閾値判定\r
int i;\r
if (th_pixcels > 0) {\r
// 黒点基準\r
for (i = 0; i < 254; i++) {\r
- th_pixcels -= i_histgram.data[i];\r
+ th_pixcels -= i_histogram.data[i];\r
if (th_pixcels <= 0) {\r
break;\r
}\r
} else {\r
// 白点基準\r
for (i = 255; i > 1; i--) {\r
- th_pixcels += i_histgram.data[i];\r
+ th_pixcels += i_histogram.data[i];\r
if (th_pixcels >= 0) {\r
break;\r
}\r
* 微分ヒストグラム法による閾値検出\r
* \r
*/\r
-public class NyARRasterThresholdAnalyzer_DiffHistgram implements INyARRasterThresholdAnalyzer\r
+public class NyARRasterThresholdAnalyzer_DiffHistogram implements INyARRasterThresholdAnalyzer\r
{\r
private int _threshold;\r
\r
- public NyARRasterThresholdAnalyzer_DiffHistgram()\r
+ public NyARRasterThresholdAnalyzer_DiffHistogram()\r
{\r
}\r
\r
- private int createHistgram(int[] in_buf,NyARIntSize i_size, int[] o_histgram) throws NyARException\r
+ private int createHistogram(int[] in_buf,NyARIntSize i_size, int[] o_histogram) throws NyARException\r
{\r
int[][] fil1={\r
{-1,-2,-1},\r
\r
// ヒストグラムを作成\r
for (int i = 0; i < 256; i++) {\r
- o_histgram[i] = 0;\r
+ o_histogram[i] = 0;\r
}\r
int sam;\r
int sam1,sam2;\r
} \r
}\r
sam=sam1*sam1+sam2*sam2;\r
- o_histgram[v]+=sam;\r
+ o_histogram[v]+=sam;\r
}\r
}\r
int th=0;\r
- int max=o_histgram[0];\r
+ int max=o_histogram[0];\r
for(int i=1;i<256;i++){\r
- if(max<o_histgram[i]){\r
+ if(max<o_histogram[i]){\r
th=i;\r
- max=o_histgram[i];\r
+ max=o_histogram[i];\r
}\r
}\r
return th;\r
public int analyzeRaster(INyARRaster i_input) throws NyARException\r
{\r
assert (i_input.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
- int[] histgram = new int[256];\r
- return createHistgram((int[])i_input.getBuffer(),i_input.getSize(), histgram);\r
+ int[] histogram = new int[256];\r
+ return createHistogram((int[])i_input.getBuffer(),i_input.getSize(), histogram);\r
}\r
\r
/**\r
* @param i_output\r
* 書き出し先のラスタオブジェクト 256ピクセル以上の幅があること。\r
*/\r
- public void debugDrawHistgramMap(INyARRaster i_input, INyARRaster i_output) throws NyARException\r
+ public void debugDrawHistogramMap(INyARRaster i_input, INyARRaster i_output) throws NyARException\r
{\r
assert (i_input.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
assert (i_output.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
}\r
}\r
// ヒストグラムを計算\r
- int[] histgram = new int[256];\r
- int threshold = createHistgram((int[])i_input.getBuffer(),i_input.getSize(), histgram);\r
+ int[] histogram = new int[256];\r
+ int threshold = createHistogram((int[])i_input.getBuffer(),i_input.getSize(), histogram);\r
\r
// ヒストグラムの最大値を出す\r
int max_v = 0;\r
for (int i = 0; i < 255; i++) {\r
- if (max_v < histgram[i]) {\r
- max_v = histgram[i];\r
+ if (max_v < histogram[i]) {\r
+ max_v = histogram[i];\r
}\r
}\r
// 目盛り\r
}\r
// スケーリングしながら描画\r
for (int i = 0; i < 255; i++) {\r
- out_buf[(histgram[i] * (size.h - 1) / max_v)* size.w+i] = 255;\r
+ out_buf[(histogram[i] * (size.h - 1) / max_v)* size.w+i] = 255;\r
}\r
// 値\r
for (int i = 0; i < size.h; i++) {\r
import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabeling_ARToolKit;
import jp.nyatla.nyartoolkit.core.param.*;
import jp.nyatla.nyartoolkit.core.raster.*;
-import jp.nyatla.nyartoolkit.core.rasteranalyzer.threshold.NyARRasterThresholdAnalyzer_DiffHistgram;
+import jp.nyatla.nyartoolkit.core.rasteranalyzer.threshold.NyARRasterThresholdAnalyzer_DiffHistogram;
import jp.nyatla.nyartoolkit.core.rasterfilter.*;
import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs.*;
import jp.nyatla.nyartoolkit.core.rasterfilter.gs2bin.*;
private NyARBinRaster _binraster1 = new NyARBinRaster(320, 240);
private NyARGrayscaleRaster _gsraster1 = new NyARGrayscaleRaster(320, 240);
- private INyARRasterThresholdAnalyzer _tha=new NyARRasterThresholdAnalyzer_DiffHistgram();
+ private INyARRasterThresholdAnalyzer _tha=new NyARRasterThresholdAnalyzer_DiffHistogram();
private LabelingBufferdImage _bimg = new LabelingBufferdImage(320, 240);
this.getGraphics().drawImage(this._bimg, 32 + 320, 32 + 240, 320 + 32 + 320, 240 + 32 + 240, 0, 240, 320, 0, this);
// 画像3
- // threshold.debugDrawHistgramMap(_workraster, _workraster2);
+ // threshold.debugDrawHistogramMap(_workraster, _workraster2);
// this._bimg2.setImage(this._workraster2);
// this.getGraphics().drawImage(this._bimg2, 32+320, 32+240,320+32+320,240+32+240,0,240,320,0, this);
// 画像5
/*
- * threshold2.debugDrawHistgramMap(_workraster, _workraster2); this._bimg2.drawImage(this._workraster2); this.getGraphics().drawImage(this._bimg2,
+ * threshold2.debugDrawHistogramMap(_workraster, _workraster2); this._bimg2.drawImage(this._workraster2); this.getGraphics().drawImage(this._bimg2,
* 32+320, 32+480,320+32+320,480+32+240,0,240,320,0, this);
*/
import jp.nyatla.nyartoolkit.core.transmat.*;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
import jp.nyatla.nyartoolkit.core.rasterfilter.gs2bin.*;\r
-import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.NyARRasterFilterBuilder_RgbToBin;\r
import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.NyARRasterFilter_ARToolkitThreshold;\r
import jp.nyatla.nyartoolkit.core.squaredetect.INyARSquareContourDetector;\r
import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabeling_ARToolKit;
import jp.nyatla.nyartoolkit.core.param.*;
import jp.nyatla.nyartoolkit.core.raster.*;
-import jp.nyatla.nyartoolkit.core.rasteranalyzer.threshold.NyARRasterThresholdAnalyzer_DiffHistgram;
+import jp.nyatla.nyartoolkit.core.rasteranalyzer.threshold.NyARRasterThresholdAnalyzer_DiffHistogram;
import jp.nyatla.nyartoolkit.core.rasterfilter.*;
import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs.INyARRasterFilter_Rgb2Gs;
import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquareStack;
private NyARBinRaster _binraster1 = new NyARBinRaster(160,120);
private NyARGrayscaleRaster _gsraster1 = new NyARGrayscaleRaster(320, 240);
- private INyARRasterThresholdAnalyzer _tha=new NyARRasterThresholdAnalyzer_DiffHistgram();
+ private INyARRasterThresholdAnalyzer _tha=new NyARRasterThresholdAnalyzer_DiffHistogram();
private LabelingBufferdImage _bimg = new LabelingBufferdImage(320, 240);
private LabelingBufferdImage _bimg2 = new LabelingBufferdImage(160, 120);
+++ /dev/null
-package jp.nyatla.nyartoolkit.core.analyzer.histgram;\r
-\r
-import jp.nyatla.nyartoolkit.core.types.NyARHistgram;\r
-\r
-public interface INyARHistgramAnalyzer_Threshold\r
-{\r
- /**\r
- * ヒストグラムから閾値探索をします。\r
- * @param i_histgram\r
- * ヒストグラム\r
- * @return\r
- */\r
- public int getThreshold(NyARHistgram i_histgram);\r
-}\r
--- /dev/null
+package jp.nyatla.nyartoolkit.core.analyzer.histogram;\r
+\r
+import jp.nyatla.nyartoolkit.core.types.NyARHistogram;\r
+\r
+public interface INyARHistogramAnalyzer_Threshold\r
+{\r
+ /**\r
+ * ヒストグラムから閾値探索をします。\r
+ * @param i_histogram\r
+ * ヒストグラム\r
+ * @return\r
+ */\r
+ public int getThreshold(NyARHistogram i_histogram);\r
+}\r
-package jp.nyatla.nyartoolkit.core.analyzer.histgram;\r
+package jp.nyatla.nyartoolkit.core.analyzer.histogram;\r
\r
-import jp.nyatla.nyartoolkit.core.types.NyARHistgram;\r
+import jp.nyatla.nyartoolkit.core.types.NyARHistogram;\r
\r
/**\r
* 判別法で閾値を求めます。\r
* 画素数が2048^2に満たない場合は、fixedint(24-8)で計算できます。\r
- * @param i_histgram\r
+ * @param i_histogram\r
* @param o_value\r
* @return\r
*/\r
-public class NyARHistgramAnalyzer_DiscriminantThreshold implements INyARHistgramAnalyzer_Threshold\r
+public class NyARHistogramAnalyzer_DiscriminantThreshold implements INyARHistogramAnalyzer_Threshold\r
{\r
private double _score;\r
\r
\r
- public int getThreshold(NyARHistgram i_histgram)\r
+ public int getThreshold(NyARHistogram i_histogram)\r
{\r
- int[] hist=i_histgram.data;\r
- int n=i_histgram.length;\r
+ int[] hist=i_histogram.data;\r
+ int n=i_histogram.length;\r
int da,sa,db,sb,dt,pt,st;\r
int i; \r
int th=0;\r
dt+=h*i;\r
pt+=h*i*i;//正規化の時に使う定数\r
}\r
- st=i_histgram.total_of_data;\r
+ st=i_histogram.total_of_data;\r
//Low側(0<=i<=n-2)\r
da=dt;\r
sa=st;\r
*/\r
public static void main(String[] args)\r
{\r
- NyARHistgram data=new NyARHistgram(256);\r
+ NyARHistogram data=new NyARHistogram(256);\r
for(int i=0;i<256;i++){\r
data.data[i]=128-i>0?128-i:i-128;\r
}\r
data.total_of_data=data.getTotal(0,255);\r
- NyARHistgramAnalyzer_DiscriminantThreshold an=new NyARHistgramAnalyzer_DiscriminantThreshold();\r
+ NyARHistogramAnalyzer_DiscriminantThreshold an=new NyARHistogramAnalyzer_DiscriminantThreshold();\r
int th=an.getThreshold(data);\r
System.out.print(th);\r
return;\r
-package jp.nyatla.nyartoolkit.core.analyzer.histgram;\r
+package jp.nyatla.nyartoolkit.core.analyzer.histogram;\r
\r
-import jp.nyatla.nyartoolkit.core.types.NyARHistgram;\r
+import jp.nyatla.nyartoolkit.core.types.NyARHistogram;\r
\r
\r
/**\r
* kittlerThresholdの方式で閾値を求めます。\r
- * @param i_histgram\r
+ * @param i_histogram\r
* @return\r
*/\r
-public class NyARHistgramAnalyzer_KittlerThreshold implements INyARHistgramAnalyzer_Threshold\r
+public class NyARHistogramAnalyzer_KittlerThreshold implements INyARHistogramAnalyzer_Threshold\r
{\r
- public int getThreshold(NyARHistgram i_histgram)\r
+ public int getThreshold(NyARHistogram i_histogram)\r
{\r
int i; \r
double min=Double.MAX_VALUE;\r
int da,sa,db,sb,pa,pb;\r
double oa,ob;\r
\r
- int[] hist=i_histgram.data;\r
- int n=i_histgram.length;\r
+ int[] hist=i_histogram.data;\r
+ int n=i_histogram.length;\r
//Low側\r
da=pa=0;\r
int h;\r
da+=h*i; //i*h[i]\r
pa+=h*i*i; //i*i*h[i]\r
}\r
- sa=i_histgram.total_of_data;\r
+ sa=i_histogram.total_of_data;\r
//High側(i=n-1)\r
db=0;\r
sb=0;\r
}\r
public static void main(String[] args)\r
{\r
- NyARHistgram data=new NyARHistgram(256);\r
+ NyARHistogram data=new NyARHistogram(256);\r
for(int i=0;i<256;i++){\r
data.data[i]=128-i>0?128-i:i-128;\r
}\r
data.total_of_data=data.getTotal(0,255);\r
- NyARHistgramAnalyzer_KittlerThreshold an=new NyARHistgramAnalyzer_KittlerThreshold();\r
+ NyARHistogramAnalyzer_KittlerThreshold an=new NyARHistogramAnalyzer_KittlerThreshold();\r
int th=an.getThreshold(data);\r
System.out.print(th);\r
return;\r
-package jp.nyatla.nyartoolkit.core.analyzer.histgram;\r
+package jp.nyatla.nyartoolkit.core.analyzer.histogram;\r
\r
-import jp.nyatla.nyartoolkit.core.types.NyARHistgram;\r
+import jp.nyatla.nyartoolkit.core.types.NyARHistogram;\r
\r
\r
\r
* \r
* \r
*/\r
-public class NyARHistgramAnalyzer_SlidePTile implements INyARHistgramAnalyzer_Threshold\r
+public class NyARHistogramAnalyzer_SlidePTile implements INyARHistogramAnalyzer_Threshold\r
{\r
private int _persentage;\r
- public NyARHistgramAnalyzer_SlidePTile(int i_persentage)\r
+ public NyARHistogramAnalyzer_SlidePTile(int i_persentage)\r
{\r
assert (0 <= i_persentage && i_persentage <= 50);\r
//初期化\r
this._persentage=i_persentage;\r
} \r
- public int getThreshold(NyARHistgram i_histgram)\r
+ public int getThreshold(NyARHistogram i_histogram)\r
{\r
//総ピクセル数を計算\r
- int n=i_histgram.length;\r
- int sum_of_pixel=i_histgram.total_of_data;\r
- int[] hist=i_histgram.data;\r
+ int n=i_histogram.length;\r
+ int sum_of_pixel=i_histogram.total_of_data;\r
+ int[] hist=i_histogram.data;\r
// 閾値ピクセル数確定\r
final int th_pixcels = sum_of_pixel * this._persentage / 100;\r
int th_wk;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
-import jp.nyatla.nyartoolkit.core.types.NyARHistgram;\r
+import jp.nyatla.nyartoolkit.core.types.NyARHistogram;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
/**\r
* 画像のヒストグラムを計算します。\r
* \r
* \r
*/\r
-public class NyARRasterAnalyzer_Histgram\r
+public class NyARRasterAnalyzer_Histogram\r
{\r
- protected ICreateHistgramImpl _histImpl;\r
+ protected ICreateHistogramImpl _histImpl;\r
/**\r
* ヒストグラム解析の縦方向スキップ数。継承クラスはこのライン数づつ\r
* スキップしながらヒストグラム計算を行うこと。\r
protected int _vertical_skip;\r
\r
\r
- public NyARRasterAnalyzer_Histgram(int i_raster_format,int i_vertical_interval) throws NyARException\r
+ public NyARRasterAnalyzer_Histogram(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
switch (i_raster_format) {\r
case INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
case INyARRaster.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
- this._histImpl = new NyARRasterThresholdAnalyzer_Histgram_BYTE1D_RGB_24();\r
+ this._histImpl = new NyARRasterThresholdAnalyzer_Histogram_BYTE1D_RGB_24();\r
break;\r
case INyARRaster.BUFFERFORMAT_INT1D_GRAY_8:\r
- this._histImpl = new NyARRasterThresholdAnalyzer_Histgram_INT1D_GRAY_8();\r
+ this._histImpl = new NyARRasterThresholdAnalyzer_Histogram_INT1D_GRAY_8();\r
break;\r
case INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8X8_32:\r
- this._histImpl = new NyARRasterThresholdAnalyzer_Histgram_BYTE1D_B8G8R8X8_32();\r
+ this._histImpl = new NyARRasterThresholdAnalyzer_Histogram_BYTE1D_B8G8R8X8_32();\r
break;\r
case INyARRaster.BUFFERFORMAT_BYTE1D_X8R8G8B8_32:\r
- this._histImpl = new NyARRasterThresholdAnalyzer_Histgram_BYTE1D_X8R8G8B8_32();\r
+ this._histImpl = new NyARRasterThresholdAnalyzer_Histogram_BYTE1D_X8R8G8B8_32();\r
break;\r
case INyARRaster.BUFFERFORMAT_WORD1D_R5G6B5_16LE:\r
- this._histImpl = new NyARRasterThresholdAnalyzer_Histgram_WORD1D_R5G6B5_16LE();\r
+ this._histImpl = new NyARRasterThresholdAnalyzer_Histogram_WORD1D_R5G6B5_16LE();\r
break;\r
case INyARRaster.BUFFERFORMAT_INT1D_X8R8G8B8_32:\r
- this._histImpl = new NyARRasterThresholdAnalyzer_Histgram_INT1D_X8R8G8B8_32();\r
+ this._histImpl = new NyARRasterThresholdAnalyzer_Histogram_INT1D_X8R8G8B8_32();\r
break;\r
default:\r
return false;\r
}\r
\r
/**\r
- * o_histgramにヒストグラムを出力します。\r
+ * o_histogramにヒストグラムを出力します。\r
* @param i_input\r
- * @param o_histgram\r
+ * @param o_histogram\r
* @return\r
* @throws NyARException\r
*/\r
- public int analyzeRaster(INyARRaster i_input,NyARHistgram o_histgram) throws NyARException\r
+ public int analyzeRaster(INyARRaster i_input,NyARHistogram o_histogram) throws NyARException\r
{\r
\r
final NyARIntSize size=i_input.getSize();\r
//最大画像サイズの制限\r
assert size.w*size.h<0x40000000;\r
- assert o_histgram.length==256;//現在は固定\r
+ assert o_histogram.length==256;//現在は固定\r
\r
- int[] h=o_histgram.data;\r
+ int[] h=o_histogram.data;\r
//ヒストグラム初期化\r
- for (int i = o_histgram.length-1; i >=0; i--){\r
+ for (int i = o_histogram.length-1; i >=0; i--){\r
h[i] = 0;\r
}\r
- o_histgram.total_of_data=size.w*size.h/this._vertical_skip;\r
- return this._histImpl.createHistgram(i_input, size,h,this._vertical_skip); \r
+ o_histogram.total_of_data=size.w*size.h/this._vertical_skip;\r
+ return this._histImpl.createHistogram(i_input, size,h,this._vertical_skip); \r
}\r
\r
- interface ICreateHistgramImpl\r
+ interface ICreateHistogramImpl\r
{\r
- public int createHistgram(INyARRaster i_reader,NyARIntSize i_size, int[] o_histgram,int i_skip);\r
+ public int createHistogram(INyARRaster i_reader,NyARIntSize i_size, int[] o_histogram,int i_skip);\r
}\r
\r
- class NyARRasterThresholdAnalyzer_Histgram_INT1D_GRAY_8 implements ICreateHistgramImpl\r
+ class NyARRasterThresholdAnalyzer_Histogram_INT1D_GRAY_8 implements ICreateHistogramImpl\r
{\r
- public int createHistgram(INyARRaster i_reader,NyARIntSize i_size, int[] o_histgram,int i_skip)\r
+ public int createHistogram(INyARRaster i_reader,NyARIntSize i_size, int[] o_histogram,int i_skip)\r
{\r
assert (i_reader.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
final int[] input=(int[]) i_reader.getBuffer();\r
for (int y = i_size.h-1; y >=0 ; y-=i_skip){\r
int pt=y*i_size.w;\r
for (int x = i_size.w-1; x >=0; x--) {\r
- o_histgram[input[pt]]++;\r
+ o_histogram[input[pt]]++;\r
pt++;\r
}\r
}\r
return i_size.w*i_size.h;\r
} \r
}\r
- class NyARRasterThresholdAnalyzer_Histgram_INT1D_X8R8G8B8_32 implements ICreateHistgramImpl\r
+ class NyARRasterThresholdAnalyzer_Histogram_INT1D_X8R8G8B8_32 implements ICreateHistogramImpl\r
{\r
- public int createHistgram(INyARRaster i_reader,NyARIntSize i_size, int[] o_histgram,int i_skip)\r
+ public int createHistogram(INyARRaster i_reader,NyARIntSize i_size, int[] o_histogram,int i_skip)\r
{\r
assert (i_reader.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_X8R8G8B8_32));\r
final int[] input=(int[]) i_reader.getBuffer();\r
int pt=y*i_size.w;\r
for (int x = i_size.w-1; x >=0; x--) {\r
int p=input[pt];\r
- o_histgram[((p& 0xff)+(p& 0xff)+(p& 0xff))/3]++;\r
+ o_histogram[((p& 0xff)+(p& 0xff)+(p& 0xff))/3]++;\r
pt++;\r
}\r
}\r
}\r
\r
\r
- class NyARRasterThresholdAnalyzer_Histgram_BYTE1D_RGB_24 implements ICreateHistgramImpl\r
+ class NyARRasterThresholdAnalyzer_Histogram_BYTE1D_RGB_24 implements ICreateHistogramImpl\r
{\r
- public int createHistgram(INyARRaster i_reader,NyARIntSize i_size, int[] o_histgram,int i_skip)\r
+ public int createHistogram(INyARRaster i_reader,NyARIntSize i_size, int[] o_histogram,int i_skip)\r
{\r
assert (\r
i_reader.isEqualBufferType(INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8_24)||\r
int x,v;\r
for (x = pix_count-1; x >=pix_mod_part; x--) {\r
v=((input[pt+0]& 0xff)+(input[pt+1]& 0xff)+(input[pt+2]& 0xff))/3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
pt+=3;\r
}\r
//タイリング\r
for (;x>=0;x-=8){\r
v=((input[pt+ 0]& 0xff)+(input[pt+ 1]& 0xff)+(input[pt+ 2]& 0xff))/3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v=((input[pt+ 3]& 0xff)+(input[pt+ 4]& 0xff)+(input[pt+ 5]& 0xff))/3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v=((input[pt+ 6]& 0xff)+(input[pt+ 7]& 0xff)+(input[pt+ 8]& 0xff))/3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v=((input[pt+ 9]& 0xff)+(input[pt+10]& 0xff)+(input[pt+11]& 0xff))/3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v=((input[pt+12]& 0xff)+(input[pt+13]& 0xff)+(input[pt+14]& 0xff))/3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v=((input[pt+15]& 0xff)+(input[pt+16]& 0xff)+(input[pt+17]& 0xff))/3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v=((input[pt+18]& 0xff)+(input[pt+19]& 0xff)+(input[pt+20]& 0xff))/3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v=((input[pt+21]& 0xff)+(input[pt+22]& 0xff)+(input[pt+23]& 0xff))/3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
pt+=3*8;\r
}\r
}\r
}\r
}\r
\r
- class NyARRasterThresholdAnalyzer_Histgram_BYTE1D_B8G8R8X8_32 implements ICreateHistgramImpl\r
+ class NyARRasterThresholdAnalyzer_Histogram_BYTE1D_B8G8R8X8_32 implements ICreateHistogramImpl\r
{\r
- public int createHistgram(INyARRaster i_reader,NyARIntSize i_size, int[] o_histgram,int i_skip)\r
+ public int createHistogram(INyARRaster i_reader,NyARIntSize i_size, int[] o_histogram,int i_skip)\r
{\r
assert(i_reader.isEqualBufferType(INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8X8_32));\r
byte[] input = (byte[])i_reader.getBuffer();\r
for (x = pix_count - 1; x >= pix_mod_part; x--)\r
{\r
v = ((input[pt + 0] & 0xff) + (input[pt + 1] & 0xff) + (input[pt + 2] & 0xff)) / 3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
pt += 4;\r
}\r
//タイリング\r
for (; x >= 0; x -= 8)\r
{\r
v = ((input[pt + 0] & 0xff) + (input[pt + 1] & 0xff) + (input[pt + 2] & 0xff)) / 3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v = ((input[pt + 4] & 0xff) + (input[pt + 5] & 0xff) + (input[pt + 6] & 0xff)) / 3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v = ((input[pt + 8] & 0xff) + (input[pt + 9] & 0xff) + (input[pt + 10] & 0xff)) / 3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v = ((input[pt + 12] & 0xff) + (input[pt + 13] & 0xff) + (input[pt + 14] & 0xff)) / 3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v = ((input[pt + 16] & 0xff) + (input[pt + 17] & 0xff) + (input[pt + 18] & 0xff)) / 3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v = ((input[pt + 20] & 0xff) + (input[pt + 21] & 0xff) + (input[pt + 22] & 0xff)) / 3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v = ((input[pt + 24] & 0xff) + (input[pt + 25] & 0xff) + (input[pt + 26] & 0xff)) / 3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v = ((input[pt + 28] & 0xff) + (input[pt + 29] & 0xff) + (input[pt + 30] & 0xff)) / 3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
pt += 4 * 8;\r
}\r
}\r
}\r
}\r
\r
- class NyARRasterThresholdAnalyzer_Histgram_BYTE1D_X8R8G8B8_32 implements ICreateHistgramImpl\r
+ class NyARRasterThresholdAnalyzer_Histogram_BYTE1D_X8R8G8B8_32 implements ICreateHistogramImpl\r
{\r
- public int createHistgram(INyARRaster i_reader,NyARIntSize i_size, int[] o_histgram,int i_skip)\r
+ public int createHistogram(INyARRaster i_reader,NyARIntSize i_size, int[] o_histogram,int i_skip)\r
{\r
assert(i_reader.isEqualBufferType(INyARRaster.BUFFERFORMAT_BYTE1D_X8R8G8B8_32));\r
byte[] input = (byte[])i_reader.getBuffer();\r
for (x = pix_count - 1; x >= pix_mod_part; x--)\r
{\r
v = ((input[pt + 1] & 0xff) + (input[pt + 2] & 0xff) + (input[pt + 3] & 0xff)) / 3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
pt += 4;\r
}\r
//タイリング\r
for (; x >= 0; x -= 8)\r
{\r
v = ((input[pt + 1] & 0xff) + (input[pt + 2] & 0xff) + (input[pt + 3] & 0xff)) / 3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v = ((input[pt + 5] & 0xff) + (input[pt + 6] & 0xff) + (input[pt + 7] & 0xff)) / 3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v = ((input[pt + 9] & 0xff) + (input[pt + 10] & 0xff) + (input[pt + 11] & 0xff)) / 3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v = ((input[pt + 13] & 0xff) + (input[pt + 14] & 0xff) + (input[pt + 15] & 0xff)) / 3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v = ((input[pt + 17] & 0xff) + (input[pt + 18] & 0xff) + (input[pt + 19] & 0xff)) / 3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v = ((input[pt + 21] & 0xff) + (input[pt + 22] & 0xff) + (input[pt + 23] & 0xff)) / 3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v = ((input[pt + 25] & 0xff) + (input[pt + 26] & 0xff) + (input[pt + 27] & 0xff)) / 3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v = ((input[pt + 29] & 0xff) + (input[pt + 30] & 0xff) + (input[pt + 31] & 0xff)) / 3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
pt += 4 * 8;\r
}\r
}\r
}\r
}\r
\r
- class NyARRasterThresholdAnalyzer_Histgram_WORD1D_R5G6B5_16LE implements ICreateHistgramImpl\r
+ class NyARRasterThresholdAnalyzer_Histogram_WORD1D_R5G6B5_16LE implements ICreateHistogramImpl\r
{\r
- public int createHistgram(INyARRaster i_reader,NyARIntSize i_size, int[] o_histgram,int i_skip)\r
+ public int createHistogram(INyARRaster i_reader,NyARIntSize i_size, int[] o_histogram,int i_skip)\r
{\r
assert(i_reader.isEqualBufferType(INyARRaster.BUFFERFORMAT_WORD1D_R5G6B5_16LE));\r
short[] input = (short[])i_reader.getBuffer();\r
{\r
v =(int)input[pt];\r
v = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))/3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
pt++;\r
}\r
//タイリング\r
{\r
v =(int)input[pt];pt++;\r
v = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))/3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v =(int)input[pt];pt++;\r
v = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))/3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v =(int)input[pt];pt++;\r
v = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))/3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v =(int)input[pt];pt++;\r
v = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))/3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v =(int)input[pt];pt++;\r
v = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))/3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v =(int)input[pt];pt++;\r
v = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))/3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v =(int)input[pt];pt++;\r
v = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))/3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
v =(int)input[pt];pt++;\r
v = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))/3;\r
- o_histgram[v]++;\r
+ o_histogram[v]++;\r
}\r
}\r
return i_size.w*i_size.h;\r
package jp.nyatla.nyartoolkit.core.analyzer.raster.threshold;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.analyzer.histgram.*;\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.NyARHistgram;\r
+import jp.nyatla.nyartoolkit.core.types.NyARHistogram;\r
/**\r
* 明点と暗点をPタイル法で検出して、その中央値を閾値とする。\r
* \r
*/\r
public class NyARRasterThresholdAnalyzer_SlidePTile implements INyARRasterThresholdAnalyzer\r
{\r
- protected NyARRasterAnalyzer_Histgram _raster_analyzer;\r
- private NyARHistgramAnalyzer_SlidePTile _sptile;\r
- private NyARHistgram _histgram;\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
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
+ 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_Histgram(i_raster_format,i_vertical_interval);\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._histgram);\r
- return this._sptile.getThreshold(this._histgram);\r
+ this._raster_analyzer.analyzeRaster(i_input, this._histogram);\r
+ return this._sptile.getThreshold(this._histogram);\r
}\r
}\r
package jp.nyatla.nyartoolkit.core.rasterfilter;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.analyzer.raster.NyARRasterAnalyzer_Histgram;\r
+import jp.nyatla.nyartoolkit.core.analyzer.raster.NyARRasterAnalyzer_Histogram;\r
import jp.nyatla.nyartoolkit.core.raster.INyARRaster;\r
-import jp.nyatla.nyartoolkit.core.types.NyARHistgram;\r
+import jp.nyatla.nyartoolkit.core.types.NyARHistogram;\r
/**\r
* ヒストグラムを平滑化します。\r
*\r
*/\r
public class NyARRasterFilter_EqualizeHist extends NyARRasterFilter_CustomToneTable\r
{\r
- private NyARRasterAnalyzer_Histgram _hist_analyzer;\r
- private NyARHistgram _histgram=new NyARHistgram(256);\r
+ private NyARRasterAnalyzer_Histogram _hist_analyzer;\r
+ private NyARHistogram _histogram=new NyARHistogram(256);\r
public NyARRasterFilter_EqualizeHist(int i_raster_type,int i_sample_interval) throws NyARException\r
{\r
super(i_raster_type);\r
- this._hist_analyzer=new NyARRasterAnalyzer_Histgram(i_raster_type,i_sample_interval);\r
+ this._hist_analyzer=new NyARRasterAnalyzer_Histogram(i_raster_type,i_sample_interval);\r
}\r
public void doFilter(INyARRaster i_input, INyARRaster i_output) throws NyARException\r
{\r
//ヒストグラムを得る\r
- NyARHistgram hist=this._histgram;\r
+ NyARHistogram hist=this._histogram;\r
this._hist_analyzer.analyzeRaster(i_input,hist);\r
//変換テーブルを作成\r
- int hist_total=this._histgram.total_of_data;\r
+ int hist_total=this._histogram.total_of_data;\r
int min=hist.getMinData();\r
- int hist_size=this._histgram.length;\r
+ int hist_size=this._histogram.length;\r
int sum=0;\r
for(int i=0;i<hist_size;i++){\r
sum+=hist.data[i];\r
/**\r
* ヒストグラムを格納するクラスです。\r
*/\r
-public class NyARHistgram\r
+public class NyARHistogram\r
{\r
/**\r
* サンプリング値の格納変数\r
\r
\r
\r
- public NyARHistgram(int i_length)\r
+ public NyARHistogram(int i_length)\r
{\r
this.data=new int[i_length];\r
this.length=i_length;\r
* @param o_out\r
* @throws NyARException\r
*/\r
- public static void copy(NyARHistgram i_in,int i_l,int i_t,int i_h,Graphics i_g) throws NyARException\r
+ public static void copy(NyARHistogram i_in,int i_l,int i_t,int i_h,Graphics i_g) throws NyARException\r
{\r
//正規化のための定数を出す。\r
int max=0;\r
this.getGraphics().drawImage(this._bimg, 32 + 320, 32 + 240, 320 + 32 + 320, 240 + 32 + 240, 0, 240, 320, 0, this);
// 画像3
- // threshold.debugDrawHistgramMap(_workraster, _workraster2);
+ // threshold.debugDrawHistogramMap(_workraster, _workraster2);
// this._bimg2.setImage(this._workraster2);
// this.getGraphics().drawImage(this._bimg2, 32+320, 32+240,320+32+320,240+32+240,0,240,320,0, this);
// 画像5
/*
- * threshold2.debugDrawHistgramMap(_workraster, _workraster2); this._bimg2.drawImage(this._workraster2); this.getGraphics().drawImage(this._bimg2,
+ * threshold2.debugDrawHistogramMap(_workraster, _workraster2); this._bimg2.drawImage(this._workraster2); this.getGraphics().drawImage(this._bimg2,
* 32+320, 32+480,320+32+320,480+32+240,0,240,320,0, this);
*/