OSDN Git Service

git-svn-id: http://svn.sourceforge.jp/svnroot/nyartoolkit/NyARToolkit/trunk@811 7cac0...
[nyartoolkit-and/nyartoolkit-and.git] / lib / src / jp / nyatla / nyartoolkit / core / rasterfilter / rgb2bin / NyARRasterFilter_ARToolkitThreshold.java
1 package jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin;\r
2 \r
3 import jp.nyatla.nyartoolkit.NyARException;\r
4 import jp.nyatla.nyartoolkit.core.raster.*;\r
5 import jp.nyatla.nyartoolkit.core.raster.rgb.INyARRgbRaster;\r
6 import jp.nyatla.nyartoolkit.core.types.NyARBufferType;\r
7 import jp.nyatla.nyartoolkit.core.types.NyARIntRect;\r
8 import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
9 \r
10 \r
11 \r
12 /**\r
13  * この関数は、ARToolKit互換のアルゴリズムでRGBラスタを2値画像へ変換します。\r
14  * <p>ARToolKitのアルゴリズム -\r
15  * ARToolKitでは、敷居値thと、RGB成分 R,G,Bから、次の式で2値画素を求めます。\r
16  * <pre>A=th*3<(R+G+B)?0:1</pre>\r
17  * </p>\r
18  * <p>入力可能な画素形式\r
19  * 入力可能な画素形式は以下の通りです。\r
20  * <ul>\r
21  * <li>{@link NyARBufferType#BYTE1D_B8G8R8_24}\r
22  * <li>{@link NyARBufferType#BYTE1D_R8G8B8_24}\r
23  * <li>{@link NyARBufferType#BYTE1D_B8G8R8X8_32}\r
24  * <li>{@link NyARBufferType#BYTE1D_X8R8G8B8_32}\r
25  * <li>{@link NyARBufferType#INT1D_X8R8G8B8_32}\r
26  * <li>{@link NyARBufferType#WORD1D_R5G6B5_16LE}\r
27  * </ul>\r
28  * </p>\r
29  * <p>出力可能な画素形式\r
30  * 出力可能な画素形式は1種類です。\r
31  * <ul>\r
32  * <li>{@link NyARBufferType#INT1D_BIN_8}\r
33  * </ul>\r
34  * </p>\r
35  */\r
36 public class NyARRasterFilter_ARToolkitThreshold implements INyARRasterFilter_Rgb2Bin\r
37 {\r
38         /** 敷居値*/\r
39         protected int _threshold;\r
40         private IdoThFilterImpl _do_threshold_impl;\r
41         /**\r
42          * コンストラクタです。\r
43          * 固定式位置の初期値、入力ラスタの画素形式を指定して、フィルタを作成します。\r
44          * 出力ラスタの形式は、{@link NyARBufferType#INT1D_BIN_8}を選択します。\r
45          * @param i_threshold\r
46          * 敷居値の初期値です。0&lt;n&lt;256の値を指定します。\r
47          * @param i_in_raster_type\r
48          * 入力ラスタの形式です。\r
49          * @throws NyARException\r
50          */\r
51         public NyARRasterFilter_ARToolkitThreshold(int i_threshold,int i_in_raster_type) throws NyARException\r
52         {\r
53                 if(!initInstance(i_threshold,i_in_raster_type,NyARBufferType.INT1D_BIN_8)){\r
54                         throw new NyARException();\r
55                 }\r
56         }\r
57         /**\r
58          * コンストラクタです。\r
59          * 固定式位置の初期値、入力、出力ラスタの画素形式を指定して、フィルタを作成します。\r
60          * @param i_threshold\r
61          * 敷居値の初期値です。0&lt;n&lt;256の値を指定します。\r
62          * @param i_in_raster_type\r
63          * 入力ラスタの形式です。\r
64          * @param i_out_raster_type\r
65          * 出力ラスタの形式です。\r
66          * @throws NyARException\r
67          */\r
68         public NyARRasterFilter_ARToolkitThreshold(int i_threshold,int i_in_raster_type,int i_out_raster_type) throws NyARException\r
69         {\r
70                 if(!initInstance(i_threshold,i_in_raster_type,i_out_raster_type)){\r
71                         throw new NyARException();\r
72                 }\r
73         }\r
74         /**\r
75          * この関数は、クラスを初期化します。\r
76          * コンストラクタから呼び出します。\r
77          * @param i_threshold\r
78          * 敷居値の初期値です。0以上、256未満の数値を指定します。\r
79          * @param i_in_raster_type\r
80          * 入力ラスタの画素形式を指定します。\r
81          * @param i_out_raster_type\r
82          * 出力ラスタの画素形式を指定します。\r
83          * @return\r
84          * 初期化に成功すると、trueを返します。\r
85          */\r
86         protected boolean initInstance(int i_threshold,int i_in_raster_type,int i_out_raster_type)\r
87         {\r
88                 switch(i_out_raster_type){\r
89                 case NyARBufferType.INT1D_BIN_8:\r
90                         switch (i_in_raster_type){\r
91                         case NyARBufferType.BYTE1D_B8G8R8_24:\r
92                         case NyARBufferType.BYTE1D_R8G8B8_24:\r
93                                 this._do_threshold_impl=new doThFilterImpl_BUFFERFORMAT_BYTE1D_RGB_24();\r
94                                 break;\r
95                         case NyARBufferType.BYTE1D_B8G8R8X8_32:\r
96                                 this._do_threshold_impl=new doThFilterImpl_BUFFERFORMAT_BYTE1D_B8G8R8X8_32();\r
97                                 break;\r
98                         case NyARBufferType.BYTE1D_X8R8G8B8_32:\r
99                                 this._do_threshold_impl=new doThFilterImpl_BUFFERFORMAT_BYTE1D_X8R8G8B8_32();\r
100                                 break;\r
101                         case NyARBufferType.INT1D_X8R8G8B8_32:\r
102                                 this._do_threshold_impl=new doThFilterImpl_BUFFERFORMAT_INT1D_X8R8G8B8_32();\r
103                                 break;\r
104                         case NyARBufferType.WORD1D_R5G6B5_16LE:\r
105                                 this._do_threshold_impl=new doThFilterImpl_BUFFERFORMAT_WORD1D_R5G6B5_16LE();\r
106                                 break;\r
107                         default:\r
108                                 return false;//サポートしない組み合わせ\r
109                         }\r
110                         break;\r
111                 default:\r
112                         return false;//サポートしない組み合わせ\r
113                 }\r
114                 this._threshold = i_threshold;\r
115                 return true;\r
116         }       \r
117         \r
118         /**\r
119          * この関数は、敷居値を設定します。\r
120          * 0以上、256未満の数値を指定してください。\r
121          * @param i_threshold\r
122          * 設定する敷居値\r
123          */\r
124         public void setThreshold(int i_threshold)\r
125         {\r
126                 this._threshold = i_threshold;\r
127         }\r
128         /**\r
129          * この関数は、入力画像を2値化した画像を出力画像へ書込みます。\r
130          * 入力画像と出力画像のサイズは同じである必要があります。\r
131          */\r
132         public void doFilter(INyARRgbRaster i_input, NyARBinRaster i_output) throws NyARException\r
133         {\r
134                 assert (i_input.getSize().isEqualSize(i_output.getSize()) == true);\r
135                 NyARIntSize s=i_input.getSize();\r
136                 this._do_threshold_impl.doThFilter(i_input,0,0,s.w,s.h,this._threshold,i_output);\r
137                 return;\r
138         }\r
139         /**\r
140          * この関数は、入力画像の一部分だけを2値化して、出力画像の該当位置へ書込みます。\r
141          * 入力画像と出力画像のサイズは同じである必要があります。\r
142          * @param i_input\r
143          * 入力画像\r
144          * @param i_area\r
145          * 2値化する矩形範囲。入力画像の範囲内である必要があります。\r
146          * @param i_output\r
147          * 出力画像\r
148          * @throws NyARException\r
149          */\r
150         public void doFilter(INyARRgbRaster i_input,NyARIntRect i_area, NyARBinRaster i_output) throws NyARException\r
151         {\r
152                 assert (i_input.getSize().isEqualSize(i_output.getSize()) == true);\r
153                 this._do_threshold_impl.doThFilter(i_input,i_area.x,i_area.y,i_area.w,i_area.h,this._threshold,i_output);\r
154                 return;\r
155                 \r
156         }\r
157         \r
158 \r
159         /** フィルタ関数の定義*/\r
160         protected interface IdoThFilterImpl\r
161         {\r
162                 public void doThFilter(INyARRaster i_raster,int i_l,int i_t,int i_w,int i_h,int i_th,INyARRaster o_raster);\r
163         }\r
164         \r
165         private class doThFilterImpl_BUFFERFORMAT_BYTE1D_RGB_24 implements IdoThFilterImpl\r
166         {\r
167                 public void doThFilter(INyARRaster i_raster,int i_l,int i_t,int i_w,int i_h,int i_th,INyARRaster o_raster)\r
168                 {\r
169                         assert (\r
170                                         i_raster.isEqualBufferType(NyARBufferType.BYTE1D_B8G8R8_24)||\r
171                                         i_raster.isEqualBufferType(NyARBufferType.BYTE1D_R8G8B8_24));\r
172                         final byte[] input=(byte[])i_raster.getBuffer();\r
173                         final int[] output=(int[])o_raster.getBuffer();\r
174                         int th=i_th*3;\r
175                         NyARIntSize s=i_raster.getSize();\r
176                         int skip_dst=(s.w-i_w);\r
177                         int skip_src=skip_dst*3;\r
178                         final int pix_count=i_w;\r
179                         final int pix_mod_part=pix_count-(pix_count%8);                 \r
180                         //左上から1行づつ走査していく\r
181                         int pt_dst=(i_t*s.w+i_l);\r
182                         int pt_src=pt_dst*3;\r
183                         for (int y = i_h-1; y >=0 ; y-=1){\r
184                                 int x;\r
185                                 for (x = pix_count-1; x >=pix_mod_part; x--){\r
186                                         output[pt_dst++]=((input[pt_src+0]& 0xff)+(input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff))<=th?0:1;\r
187                                         pt_src+=3;\r
188                                 }\r
189                                 for (;x>=0;x-=8){\r
190                                         output[pt_dst++]=((input[pt_src+0]& 0xff)+(input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff))<=th?0:1;\r
191                                         pt_src+=3;\r
192                                         output[pt_dst++]=((input[pt_src+0]& 0xff)+(input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff))<=th?0:1;\r
193                                         pt_src+=3;\r
194                                         output[pt_dst++]=((input[pt_src+0]& 0xff)+(input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff))<=th?0:1;\r
195                                         pt_src+=3;\r
196                                         output[pt_dst++]=((input[pt_src+0]& 0xff)+(input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff))<=th?0:1;\r
197                                         pt_src+=3;\r
198                                         output[pt_dst++]=((input[pt_src+0]& 0xff)+(input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff))<=th?0:1;\r
199                                         pt_src+=3;\r
200                                         output[pt_dst++]=((input[pt_src+0]& 0xff)+(input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff))<=th?0:1;\r
201                                         pt_src+=3;\r
202                                         output[pt_dst++]=((input[pt_src+0]& 0xff)+(input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff))<=th?0:1;\r
203                                         pt_src+=3;\r
204                                         output[pt_dst++]=((input[pt_src+0]& 0xff)+(input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff))<=th?0:1;\r
205                                         pt_src+=3;\r
206                                 }\r
207                                 //スキップ\r
208                                 pt_src+=skip_src;\r
209                                 pt_dst+=skip_dst;\r
210                         }\r
211                         return; \r
212                 }\r
213         }\r
214         private class doThFilterImpl_BUFFERFORMAT_INT1D_X8R8G8B8_32 implements IdoThFilterImpl\r
215         {\r
216                 public void doThFilter(INyARRaster i_raster,int i_l,int i_t,int i_w,int i_h,int i_th,INyARRaster o_raster)\r
217                 {\r
218                         assert (i_raster.isEqualBufferType( NyARBufferType.INT1D_X8R8G8B8_32));\r
219                         final int[] input=(int[])i_raster.getBuffer();\r
220                         final int[] output=(int[])o_raster.getBuffer();\r
221                         int th=i_th*3;\r
222 \r
223                         NyARIntSize s=i_raster.getSize();\r
224                         int skip_src=(s.w-i_w);\r
225                         int skip_dst=skip_src;\r
226                         final int pix_count=i_w;\r
227                         final int pix_mod_part=pix_count-(pix_count%8);                 \r
228                         //左上から1行づつ走査していく\r
229                         int pt_dst=(i_t*s.w+i_l);\r
230                         int pt_src=pt_dst;\r
231                         for (int y = i_h-1; y >=0 ; y-=1){\r
232                                 int x,v;\r
233                                 for (x = pix_count-1; x >=pix_mod_part; x--){\r
234                                         v=input[pt_src++];output[pt_dst++]=(((v>>16)& 0xff)+((v>>8)& 0xff)+(v& 0xff))<=th?0:1;\r
235                                 }\r
236                                 for (;x>=0;x-=8){\r
237                                         v=input[pt_src++];output[pt_dst++]=(((v>>16)& 0xff)+((v>>8)& 0xff)+(v& 0xff))<=th?0:1;\r
238                                         v=input[pt_src++];output[pt_dst++]=(((v>>16)& 0xff)+((v>>8)& 0xff)+(v& 0xff))<=th?0:1;\r
239                                         v=input[pt_src++];output[pt_dst++]=(((v>>16)& 0xff)+((v>>8)& 0xff)+(v& 0xff))<=th?0:1;\r
240                                         v=input[pt_src++];output[pt_dst++]=(((v>>16)& 0xff)+((v>>8)& 0xff)+(v& 0xff))<=th?0:1;\r
241                                         v=input[pt_src++];output[pt_dst++]=(((v>>16)& 0xff)+((v>>8)& 0xff)+(v& 0xff))<=th?0:1;\r
242                                         v=input[pt_src++];output[pt_dst++]=(((v>>16)& 0xff)+((v>>8)& 0xff)+(v& 0xff))<=th?0:1;\r
243                                         v=input[pt_src++];output[pt_dst++]=(((v>>16)& 0xff)+((v>>8)& 0xff)+(v& 0xff))<=th?0:1;\r
244                                         v=input[pt_src++];output[pt_dst++]=(((v>>16)& 0xff)+((v>>8)& 0xff)+(v& 0xff))<=th?0:1;\r
245                                 }\r
246                                 //スキップ\r
247                                 pt_src+=skip_src;\r
248                                 pt_dst+=skip_dst;                               \r
249                         }\r
250                         return;                 \r
251                 }       \r
252         }\r
253 \r
254         \r
255 \r
256 \r
257         private class doThFilterImpl_BUFFERFORMAT_BYTE1D_B8G8R8X8_32 implements IdoThFilterImpl\r
258         {\r
259                 public void doThFilter(INyARRaster i_raster,int i_l,int i_t,int i_w,int i_h,int i_th,INyARRaster o_raster)\r
260                 {\r
261                 assert(i_raster.isEqualBufferType(NyARBufferType.BYTE1D_B8G8R8X8_32));\r
262                         final byte[] input=(byte[])i_raster.getBuffer();\r
263                         final int[] output=(int[])o_raster.getBuffer();\r
264                         NyARIntSize s=i_raster.getSize();\r
265                         int th=i_th*3;\r
266                         int skip_dst=(s.w-i_w);\r
267                         int skip_src=skip_dst*4;\r
268                         final int pix_count=i_w;\r
269                         final int pix_mod_part=pix_count-(pix_count%8);                 \r
270                         //左上から1行づつ走査していく\r
271                         int pt_dst=(i_t*s.w+i_l);\r
272                         int pt_src=pt_dst*4;\r
273                         for (int y = i_h-1; y >=0 ; y-=1){\r
274                                 int x;\r
275                                 for (x = pix_count-1; x >=pix_mod_part; x--){\r
276                                         output[pt_dst++]=((input[pt_src+ 0]& 0xff)+(input[pt_src+ 1]& 0xff)+(input[pt_src+ 2]& 0xff))<=th?0:1;\r
277                                         pt_src+=4;\r
278                                 }\r
279                                 for (;x>=0;x-=8){\r
280                                         output[pt_dst++]=((input[pt_src+0]& 0xff)+(input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff))<=th?0:1;\r
281                                         pt_src+=4;\r
282                                         output[pt_dst++]=((input[pt_src+0]& 0xff)+(input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff))<=th?0:1;\r
283                                         pt_src+=4;\r
284                                         output[pt_dst++]=((input[pt_src+0]& 0xff)+(input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff))<=th?0:1;\r
285                                         pt_src+=4;\r
286                                         output[pt_dst++]=((input[pt_src+0]& 0xff)+(input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff))<=th?0:1;\r
287                                         pt_src+=4;\r
288                                         output[pt_dst++]=((input[pt_src+0]& 0xff)+(input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff))<=th?0:1;\r
289                                         pt_src+=4;\r
290                                         output[pt_dst++]=((input[pt_src+0]& 0xff)+(input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff))<=th?0:1;\r
291                                         pt_src+=4;\r
292                                         output[pt_dst++]=((input[pt_src+0]& 0xff)+(input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff))<=th?0:1;\r
293                                         pt_src+=4;\r
294                                         output[pt_dst++]=((input[pt_src+0]& 0xff)+(input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff))<=th?0:1;\r
295                                         pt_src+=4;\r
296                                 }\r
297                                 //スキップ\r
298                                 pt_src+=skip_src;\r
299                                 pt_dst+=skip_dst;                               \r
300                         }\r
301                         return; \r
302             }\r
303         }\r
304 \r
305         private class doThFilterImpl_BUFFERFORMAT_BYTE1D_X8R8G8B8_32 implements IdoThFilterImpl\r
306         {\r
307                 public void doThFilter(INyARRaster i_raster,int i_l,int i_t,int i_w,int i_h,int i_th,INyARRaster o_raster)\r
308                 {\r
309                 assert(i_raster.isEqualBufferType(NyARBufferType.BYTE1D_X8R8G8B8_32));\r
310                         final byte[] input=(byte[])i_raster.getBuffer();\r
311                         final int[] output=(int[])o_raster.getBuffer();\r
312                         int th=i_th*3;\r
313                         NyARIntSize s=i_raster.getSize();\r
314                         int skip_dst=(s.w-i_w);\r
315                         int skip_src=skip_dst*4;\r
316                         final int pix_count=i_w;\r
317                         final int pix_mod_part=pix_count-(pix_count%8);                 \r
318                         //左上から1行づつ走査していく\r
319                         int pt_dst=(i_t*s.w+i_l);\r
320                         int pt_src=pt_dst*4;\r
321                         for (int y = i_h-1; y >=0 ; y-=1){\r
322                                 int x;\r
323                                 for (x = pix_count-1; x >=pix_mod_part; x--){\r
324                                         output[pt_dst++]=((input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff)+(input[pt_src+3]& 0xff))<=th?0:1;\r
325                                         pt_src+=4;\r
326                                 }\r
327                                 for (;x>=0;x-=8){\r
328                                         output[pt_dst++]=((input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff)+(input[pt_src+3]& 0xff))<=th?0:1;\r
329                                         pt_src+=4;\r
330                                         output[pt_dst++]=((input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff)+(input[pt_src+3]& 0xff))<=th?0:1;\r
331                                         pt_src+=4;\r
332                                         output[pt_dst++]=((input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff)+(input[pt_src+3]& 0xff))<=th?0:1;\r
333                                         pt_src+=4;\r
334                                         output[pt_dst++]=((input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff)+(input[pt_src+3]& 0xff))<=th?0:1;\r
335                                         pt_src+=4;\r
336                                         output[pt_dst++]=((input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff)+(input[pt_src+3]& 0xff))<=th?0:1;\r
337                                         pt_src+=4;\r
338                                         output[pt_dst++]=((input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff)+(input[pt_src+3]& 0xff))<=th?0:1;\r
339                                         pt_src+=4;\r
340                                         output[pt_dst++]=((input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff)+(input[pt_src+3]& 0xff))<=th?0:1;\r
341                                         pt_src+=4;\r
342                                         output[pt_dst++]=((input[pt_src+1]& 0xff)+(input[pt_src+2]& 0xff)+(input[pt_src+3]& 0xff))<=th?0:1;\r
343                                         pt_src+=4;\r
344                                 }\r
345                                 //スキップ\r
346                                 pt_src+=skip_src;\r
347                                 pt_dst+=skip_dst;                               \r
348                         }\r
349                         return; \r
350             }\r
351         }\r
352 \r
353         private class doThFilterImpl_BUFFERFORMAT_WORD1D_R5G6B5_16LE implements IdoThFilterImpl\r
354         {\r
355                 public void doThFilter(INyARRaster i_raster,int i_l,int i_t,int i_w,int i_h,int i_th,INyARRaster o_raster)\r
356                 {\r
357                 assert(i_raster.isEqualBufferType(NyARBufferType.WORD1D_R5G6B5_16LE));\r
358                         final short[] input=(short[])i_raster.getBuffer();\r
359                         final int[] output=(int[])o_raster.getBuffer();\r
360                         int th=i_th*3;\r
361                         NyARIntSize s=i_raster.getSize();\r
362                         int skip_dst=(s.w-i_w);\r
363                         int skip_src=skip_dst;\r
364                         final int pix_count=i_w;\r
365                         final int pix_mod_part=pix_count-(pix_count%8);                 \r
366                         //左上から1行づつ走査していく\r
367                         int pt_dst=(i_t*s.w+i_l);\r
368                         int pt_src=pt_dst;\r
369                         for (int y = i_h-1; y >=0 ; y-=1){\r
370                                 int x,v;\r
371                                 for (x = pix_count-1; x >=pix_mod_part; x--){\r
372                                         v =(int)input[pt_src++]; output[pt_dst++]=(((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))<=th?0:1;\r
373                                 }\r
374                                 for (;x>=0;x-=8){\r
375                                         v =(int)input[pt_src++]; output[pt_dst++]=(((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))<=th?0:1;\r
376                                         v =(int)input[pt_src++]; output[pt_dst++]=(((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))<=th?0:1;\r
377                                         v =(int)input[pt_src++]; output[pt_dst++]=(((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))<=th?0:1;\r
378                                         v =(int)input[pt_src++]; output[pt_dst++]=(((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))<=th?0:1;\r
379                                         v =(int)input[pt_src++]; output[pt_dst++]=(((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))<=th?0:1;\r
380                                         v =(int)input[pt_src++]; output[pt_dst++]=(((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))<=th?0:1;\r
381                                         v =(int)input[pt_src++]; output[pt_dst++]=(((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))<=th?0:1;\r
382                                         v =(int)input[pt_src++]; output[pt_dst++]=(((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))<=th?0:1;\r
383                                 }\r
384                                 //スキップ\r
385                                 pt_src+=skip_src;\r
386                                 pt_dst+=skip_dst;\r
387                         }\r
388                         return; \r
389             }\r
390         }\r
391         \r
392 }\r