2 * PROJECT: NyARToolkit
\r
3 * --------------------------------------------------------------------------------
\r
4 * This work is based on the original ARToolKit developed by
\r
7 * HITLab, University of Washington, Seattle
\r
8 * http://www.hitl.washington.edu/artoolkit/
\r
10 * The NyARToolkit is Java edition ARToolKit class library.
\r
11 * Copyright (C)2008-2009 Ryo Iizuka
\r
13 * This program is free software; you can redistribute it and/or
\r
14 * modify it under the terms of the GNU Lesser General Public License
\r
15 * as published by the Free Software Foundation; either version 3
\r
16 * of the License, or (at your option) any later version.
\r
18 * This program is distributed in the hope that it will be useful,
\r
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
21 * GNU Lesser General Public License for more details
\r
23 * You should have received a copy of the GNU Lesser General Public
\r
24 * License along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
26 * For further information please contact.
\r
27 * http://nyatla.jp/nyatoolkit/
\r
28 * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
\r
31 package jp.nyatla.nyartoolkit.core.match;
\r
34 import jp.nyatla.nyartoolkit.core.raster.*;
\r
38 * INyARMatchPattのColor差分ラスタを格納するクラスです。
\r
41 public class NyARMatchPattDeviationBlackWhiteData
\r
43 private int _data[];
\r
44 private double _pow;
\r
46 private int _number_of_pixels;
\r
47 public int[] refData()
\r
51 public double getPow()
\r
56 public NyARMatchPattDeviationBlackWhiteData(int i_width,int i_height)
\r
58 this._number_of_pixels=i_height*i_width;
\r
59 this._data=new int[this._number_of_pixels];
\r
63 * XRGB[width*height]の配列から、パターンデータを構築。
\r
66 public void setRaster(INyARRaster i_raster)
\r
68 //i_buffer[XRGB]→差分[BW]変換
\r
72 final int[] linput=this._data;//<PV/>
\r
73 final int[] buf=(int[])i_raster.getBufferReader().getBuffer();
\r
75 // input配列のサイズとwhも更新// input=new int[height][width][3];
\r
76 final int number_of_pixels=this._number_of_pixels;
\r
78 //<平均値計算(FORの1/8展開)/>
\r
80 for(i=number_of_pixels-1;i>=0;i--){
\r
82 ave += ((rgb >> 16) & 0xff) + ((rgb >> 8) & 0xff) + (rgb & 0xff);
\r
84 ave=(number_of_pixels*255*3-ave)/(3*number_of_pixels);
\r
89 for (i = number_of_pixels-1; i >= 0;i--) {
\r
91 w_sum =((255*3-(rgb & 0xff)-((rgb >> 8) & 0xff)-((rgb >> 16) & 0xff))/3)-ave;
\r
93 sum += w_sum * w_sum;
\r
95 final double p=Math.sqrt((double) sum);
\r
96 this._pow=p!=0.0?p:0.0000001;
\r