/**
         * ラスタの指定点を基点に、輪郭線を抽出します。開始点は、輪郭の一部、かつ左上のエッジで有る必要があります。
         * @param i_raster
         * 輪郭線を抽出するラスタを指定します。
         * @param i_th
         * 輪郭とみなす暗点の敷居値を指定します。
         * @param i_entry_x
         * 輪郭抽出の開始点です。
         * @param i_entry_y
         * 輪郭抽出の開始点です。
         * @param o_coord
         * 輪郭点を格納する配列を指定します。i_array_sizeよりも大きなサイズの配列が必要です。
         * @return
         * 輪郭の抽出に成功するとtrueを返します。輪郭抽出に十分なバッファが無いと、falseになります。
         * @throws NyARException
         */
        public bool getContour(NyARGrayscaleRaster i_raster, int i_th, int i_entry_x, int i_entry_y, NyARIntCoordinates o_coord)
        {
            Debug.Assert(i_raster.isEqualBufferType(NyARBufferType.INT1D_GRAY_8));
            NyARIntSize s = i_raster.getSize();

            return(impl_getContour(i_raster, 0, 0, s.w - 1, s.h - 1, i_th, i_entry_x, i_entry_y, o_coord));
        }
        /**
         * GSラスタの2値ラべリングを実行します。
         * @param i_gs_raster
         * @param i_th
         * 二値化の敷居値を指定します。
         * @param o_stack
         * 結果を蓄積するスタックオブジェクトを指定します。
         * 関数は、このオブジェクトに結果を追記します。
         * @return
         * @throws NyARException
         */
        public virtual void labeling(NyARGrayscaleRaster i_gs_raster, int i_th)
        {
            Debug.Assert(i_gs_raster.isEqualBufferType(NyARBufferType.INT1D_GRAY_8));
            NyARIntSize size = i_gs_raster.getSize();

            this.imple_labeling(i_gs_raster, i_th, 0, 0, size.w, size.h);
        }
            public void copyTo(NyARGrayscaleRaster i_input, int i_left, int i_top, int i_skip, NyARGrayscaleRaster o_output)
            {
                Debug.Assert(i_input.getSize().isInnerSize(i_left + o_output.getWidth() * i_skip, i_top + o_output.getHeight() * i_skip));
                int[]       input = (int[])i_input.getBuffer();
                int[]       output = (int[])o_output.getBuffer();
                int         pt_src, pt_dst;
                NyARIntSize dest_size    = o_output.getSize();
                NyARIntSize src_size     = i_input.getSize();
                int         skip_src_y   = (src_size.w - dest_size.w * i_skip) + src_size.w * (i_skip - 1);
                int         pix_count    = dest_size.w;
                int         pix_mod_part = pix_count - (pix_count % 8);

                // 左上から1行づつ走査していく
                pt_dst = 0;
                pt_src = (i_top * src_size.w + i_left);
                for (int y = dest_size.h - 1; y >= 0; y -= 1)
                {
                    int x;
                    for (x = pix_count - 1; x >= pix_mod_part; x--)
                    {
                        output[pt_dst++] = input[pt_src];
                        pt_src          += i_skip;
                    }
                    for (; x >= 0; x -= 8)
                    {
                        output[pt_dst++] = input[pt_src];
                        pt_src          += i_skip;
                        output[pt_dst++] = input[pt_src];
                        pt_src          += i_skip;
                        output[pt_dst++] = input[pt_src];
                        pt_src          += i_skip;
                        output[pt_dst++] = input[pt_src];
                        pt_src          += i_skip;
                        output[pt_dst++] = input[pt_src];
                        pt_src          += i_skip;
                        output[pt_dst++] = input[pt_src];
                        pt_src          += i_skip;
                        output[pt_dst++] = input[pt_src];
                        pt_src          += i_skip;
                        output[pt_dst++] = input[pt_src];
                        pt_src          += i_skip;
                    }
                    // スキップ
                    pt_src += skip_src_y;
                }
                return;
            }
        public void doFilter(INyARRgbRaster i_input, NyARGrayscaleRaster i_output)
        {
            Debug.Assert(i_input.getSize().isEqualSize(i_output.getSize()) == true);
            NyARIntSize s = i_input.getSize();

            this._do_filter_impl.doFilter(i_input, (int[])i_output.getBuffer(), 0, 0, s.w, s.h);
            return;
        }
            public void doCutFilter(INyARRaster i_input, int l, int t, int i_st, NyARGrayscaleRaster o_output)
            {
                Debug.Assert(i_input.isEqualBufferType(NyARBufferType.BYTE1D_B8G8R8_24) || i_input.isEqualBufferType(NyARBufferType.BYTE1D_R8G8B8_24));
                Debug.Assert(i_input.getSize().isInnerSize(l + o_output.getWidth() * i_st, t + o_output.getHeight() * i_st));

                byte[]      input = (byte[])i_input.getBuffer();
                int[]       output = (int[])o_output.getBuffer();
                int         pt_src, pt_dst;
                NyARIntSize dest_size    = o_output.getSize();
                NyARIntSize src_size     = i_input.getSize();
                int         skip_src_y   = (src_size.w - dest_size.w * i_st) * 3 + src_size.w * (i_st - 1) * 3;
                int         skip_src_x   = 3 * i_st;
                int         pix_count    = dest_size.w;
                int         pix_mod_part = pix_count - (pix_count % 8);

                //左上から1行づつ走査していく
                pt_dst = 0;
                pt_src = (t * src_size.w + l) * 3;
                for (int y = dest_size.h - 1; y >= 0; y -= 1)
                {
                    int x;
                    for (x = pix_count - 1; x >= pix_mod_part; x--)
                    {
                        output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) >> 2;
                        pt_src          += skip_src_x;
                    }
                    for (; x >= 0; x -= 8)
                    {
                        output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) >> 2;
                        pt_src          += skip_src_x;
                        output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) >> 2;
                        pt_src          += skip_src_x;
                        output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) >> 2;
                        pt_src          += skip_src_x;
                        output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) >> 2;
                        pt_src          += skip_src_x;
                        output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) >> 2;
                        pt_src          += skip_src_x;
                        output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) >> 2;
                        pt_src          += skip_src_x;
                        output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) >> 2;
                        pt_src          += skip_src_x;
                        output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) >> 2;
                        pt_src          += skip_src_x;
                    }
                    //スキップ
                    pt_src += skip_src_y;
                }
                return;
            }
        public void doFilter(NyARGrayscaleRaster i_input, NyARBinRaster i_output)
        {
            Debug.Assert(i_input.getBufferType() == NyARBufferType.INT1D_GRAY_8);
            Debug.Assert(i_output.getBufferType() == NyARBufferType.INT1D_BIN_8);
            int[]       out_buf = (int[])i_output.getBuffer();
            int[]       in_buf  = (int[])i_input.getBuffer();
            NyARIntSize s       = i_input.getSize();

            int th           = this._threshold;
            int bp           = s.w * s.h - 1;
            int pix_count    = s.h * s.w;
            int pix_mod_part = pix_count - (pix_count % 8);

            for (bp = pix_count - 1; bp >= pix_mod_part; bp--)
            {
                out_buf[bp] = (in_buf[bp] & 0xff) <= th?0:1;
            }
            //タイリング
            for (; bp >= 0;)
            {
                out_buf[bp] = (in_buf[bp] & 0xff) <= th?0:1;
                bp--;
                out_buf[bp] = (in_buf[bp] & 0xff) <= th?0:1;
                bp--;
                out_buf[bp] = (in_buf[bp] & 0xff) <= th?0:1;
                bp--;
                out_buf[bp] = (in_buf[bp] & 0xff) <= th?0:1;
                bp--;
                out_buf[bp] = (in_buf[bp] & 0xff) <= th?0:1;
                bp--;
                out_buf[bp] = (in_buf[bp] & 0xff) <= th?0:1;
                bp--;
                out_buf[bp] = (in_buf[bp] & 0xff) <= th?0:1;
                bp--;
                out_buf[bp] = (in_buf[bp] & 0xff) <= th?0:1;
                bp--;
            }
            return;
        }
	    public void doFilter(NyARGrayscaleRaster i_input, NyARBinRaster i_output)
	    {
		    Debug.Assert(i_input.getBufferType()==NyARBufferType.INT1D_GRAY_8);
		    Debug.Assert(i_output.getBufferType()==NyARBufferType.INT1D_BIN_8);
		    int[] out_buf = (int[]) i_output.getBuffer();
		    int[] in_buf = (int[]) i_input.getBuffer();
		    NyARIntSize s=i_input.getSize();
    		
		    int th=this._threshold;
		    int bp =s.w*s.h-1;
		    int pix_count   =s.h*s.w;
		    int pix_mod_part=pix_count-(pix_count%8);
		    for(bp=pix_count-1;bp>=pix_mod_part;bp--){
			    out_buf[bp]=(in_buf[bp] & 0xff)<=th?0:1;
		    }
		    //タイリング
		    for (;bp>=0;) {
			    out_buf[bp]=(in_buf[bp] & 0xff)<=th?0:1;
			    bp--;
			    out_buf[bp]=(in_buf[bp] & 0xff)<=th?0:1;
			    bp--;
			    out_buf[bp]=(in_buf[bp] & 0xff)<=th?0:1;
			    bp--;
			    out_buf[bp]=(in_buf[bp] & 0xff)<=th?0:1;
			    bp--;
			    out_buf[bp]=(in_buf[bp] & 0xff)<=th?0:1;
			    bp--;
			    out_buf[bp]=(in_buf[bp] & 0xff)<=th?0:1;
			    bp--;
			    out_buf[bp]=(in_buf[bp] & 0xff)<=th?0:1;
			    bp--;
			    out_buf[bp]=(in_buf[bp] & 0xff)<=th?0:1;
			    bp--;
		    }
		    return;			
	    }
	    public void doFilter(INyARRgbRaster i_input, NyARGrayscaleRaster i_output)
	    {
		    Debug.Assert (i_input.getSize().isEqualSize(i_output.getSize()) == true);
		    this._dofilterimpl.doFilter(i_input,i_output,i_input.getSize());
	    }
 /**
  * 同一サイズのラスタi_inputとi_outputの間で、一部の領域だけにラスタ処理を実行します。
  * @param i_input
  * @param i_rect
  * @param i_output
  * @throws NyARException
  */
 public void doFilter(INyARRgbRaster i_input, NyARIntRect i_rect, NyARGrayscaleRaster i_output)
 {
     Debug.Assert(i_input.getSize().isEqualSize(i_output.getSize()) == true);
     this._do_filter_impl.doFilter(i_input, (int[])i_output.getBuffer(), i_rect.x, i_rect.y, i_rect.w, i_rect.h);
 }
Beispiel #10
0
 public void doFilter(INyARRgbRaster i_input, NyARGrayscaleRaster i_output)
 {
     Debug.Assert(i_input.getSize().isEqualSize(i_output.getSize()) == true);
     this._do_filter_impl.doFilter(i_input, i_output, i_input.getSize());
     return;
 }