2 * PROJECT: NyARToolkit(Extension)
\r
3 * --------------------------------------------------------------------------------
\r
4 * The NyARToolkit is Java edition ARToolKit class library.
\r
5 * Copyright (C)2008-2009 Ryo Iizuka
\r
7 * This program is free software: you can redistribute it and/or modify
\r
8 * it under the terms of the GNU General Public License as published by
\r
9 * the Free Software Foundation, either version 3 of the License, or
\r
10 * (at your option) any later version.
\r
12 * This program is distributed in the hope that it will be useful,
\r
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 * GNU General Public License for more details.
\r
17 * You should have received a copy of the GNU General Public License
\r
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
20 * For further information please contact.
\r
21 * http://nyatla.jp/nyatoolkit/
\r
22 * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
\r
25 package jp.nyatla.nyartoolkit.core.rasterfilter;
\r
27 import jp.nyatla.nyartoolkit.NyARException;
\r
28 import jp.nyatla.nyartoolkit.core.raster.*;
\r
29 import jp.nyatla.nyartoolkit.core.types.NyARBufferType;
\r
30 import jp.nyatla.nyartoolkit.core.types.NyARIntSize;
\r
33 * 色調テーブルを使用したフィルターです。
\r
34 * 色調テーブルクラスのベースクラスです。
\r
36 public class NyARRasterFilter_CustomToneTable implements INyARRasterFilter
\r
38 protected final int[] table=new int[256];
\r
39 private IdoFilterImpl _dofilterimpl;
\r
40 protected NyARRasterFilter_CustomToneTable(int i_raster_type) throws NyARException
\r
42 switch (i_raster_type) {
\r
43 case NyARBufferType.INT1D_GRAY_8:
\r
44 this._dofilterimpl=new IdoFilterImpl_INT1D_GRAY_8();
\r
47 throw new NyARException();
\r
49 this._dofilterimpl._table_ref=this.table;
\r
51 public void doFilter(INyARRaster i_input, INyARRaster i_output) throws NyARException
\r
53 assert (i_input.getSize().isEqualSize(i_output.getSize()) == true);
\r
54 this._dofilterimpl.doFilter(i_input,i_output,i_input.getSize());
\r
57 private abstract class IdoFilterImpl
\r
59 public int[] _table_ref;
\r
60 public abstract void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size) throws NyARException;
\r
63 private class IdoFilterImpl_INT1D_GRAY_8 extends IdoFilterImpl
\r
65 public void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size) throws NyARException
\r
67 assert( i_input.isEqualBufferType(NyARBufferType.INT1D_GRAY_8));
\r
69 int[] out_buf = (int[]) i_output.getBuffer();
\r
70 int[] in_buf = (int[]) i_input.getBuffer();
\r
71 for(int i=i_size.h*i_size.w-1;i>=0;i--)
\r
73 out_buf[i]=this._table_ref[in_buf[i]];
\r