public override void doFilter(int i_l, int i_t, int i_w, int i_h, int i_th, INyARGrayscaleRaster i_gsraster) { Debug.Assert(i_gsraster.isEqualBufferType(NyARBufferType.INT1D_BIN_8)); INyARRgbPixelDriver input = this._raster.getRgbPixelDriver(); int[] output = (int[])i_gsraster.getBuffer(); int th = i_th * 3; NyARIntSize s = i_gsraster.getSize(); int skip_dst = (s.w - i_w); int skip_src = skip_dst; //左上から1行づつ走査していく int pt_dst = (i_t * s.w + i_l); int[] rgb = this.__rgb; for (int y = 0; y < i_h; y++) { int x; for (x = 0; x < i_w; x++) { input.getPixel(x + i_l, y + i_t, rgb); output[pt_dst++] = (rgb[0] + rgb[1] + rgb[2]) <= th ? 0 : 1; } //スキップ pt_dst += skip_dst; } return; }
public override void doFilter(int i_l, int i_t, int i_w, int i_h, int i_th, INyARGrayscaleRaster i_gsraster) { Debug.Assert(i_gsraster.isEqualBufferType(NyARBufferType.INT1D_BIN_8)); INyARRgbPixelDriver input = this._raster.getRgbPixelDriver(); int[] output = (int[])i_gsraster.getBuffer(); int th = i_th * 3; NyARIntSize s = i_gsraster.getSize(); int skip_dst = (s.w - i_w); int skip_src = skip_dst; //左上から1行づつ走査していく int pt_dst = (i_t * s.w + i_l); int[] rgb = this.__rgb; for (int y = 0; y <i_h; y++) { int x; for (x = 0; x < i_w; x++) { input.getPixel(x + i_l, y + i_t, rgb); output[pt_dst++] = (rgb[0] + rgb[1] + rgb[2]) <= th ? 0 : 1; } //スキップ pt_dst += skip_dst; } return; }
/** * 検索ウインドウは(i_px*2+1)*(i_py*2+1)サイズの矩形。 * @param i_ref_raster * @param i_search_x * 検索ウインドウの範囲を指定する。 * @param i_search_y */ public NyARTemplateMatchingDriver_INT1D(INyARGrayscaleRaster i_ref_raster, int i_search_x, int i_search_y) { Debug.Assert(i_ref_raster.isEqualBufferType(NyARBufferType.INT1D_GRAY_8)); this._i_ref_raster = i_ref_raster; this._mbuf = new byte[i_ref_raster.getWidth() * i_ref_raster.getHeight()]; this._search_area.x = i_search_x; this._search_area.y = i_search_y; }
public NyARTemplateMatchingDriver_ANY(INyARGrayscaleRaster i_ref_raster) { Debug.Assert(i_ref_raster.isEqualBufferType(NyARBufferType.INT1D_GRAY_8)); this._i_ref_raster = i_ref_raster; this._mbuf = new byte[i_ref_raster.getWidth() * i_ref_raster.getHeight()]; this._search_area.x = AR2_DEFAULT_SEARCH_SIZE; this._search_area.y = AR2_DEFAULT_SEARCH_SIZE; }
public override void doFilter(int i_l, int i_t, int i_w, int i_h, int i_th, INyARGrayscaleRaster i_gsraster) { Debug.Assert(i_gsraster.isEqualBufferType(NyARBufferType.INT1D_BIN_8)); byte[] input = (byte[])this._raster.getBuffer(); int[] output = (int[])i_gsraster.getBuffer(); int th = i_th * 3; NyARIntSize s = this._raster.getSize(); int skip_dst = (s.w - i_w); int skip_src = skip_dst * 3; int pix_count = i_w; int pix_mod_part = pix_count - (pix_count % 8); //左上から1行づつ走査していく int pt_dst = (i_t * s.w + i_l); int pt_src = pt_dst * 3; for (int y = i_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)) <= th ? 0 : 1; pt_src += 3; } for (; x >= 0; x -= 8) { output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) <= th ? 0 : 1; pt_src += 3; output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) <= th ? 0 : 1; pt_src += 3; output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) <= th ? 0 : 1; pt_src += 3; output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) <= th ? 0 : 1; pt_src += 3; output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) <= th ? 0 : 1; pt_src += 3; output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) <= th ? 0 : 1; pt_src += 3; output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) <= th ? 0 : 1; pt_src += 3; output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) <= th ? 0 : 1; pt_src += 3; } //スキップ pt_src += skip_src; pt_dst += skip_dst; } return; }
public void doFilter(int i_l, int i_t, int i_w, int i_h, int i_th, INyARGrayscaleRaster i_gsraster) { Debug.Assert(i_gsraster.isEqualBufferType(NyARBufferType.INT1D_BIN_8)); BitmapData bm = this._raster.lockBitmap(); byte[] work = this._work; int[] output = (int[])i_gsraster.getBuffer(); NyARIntSize s = this._raster.getSize(); int th = i_th * 3; int skip_dst = (s.w - i_w); int skip_src = skip_dst * 4; int pix_count = i_w; int pix_mod_part = pix_count - (pix_count % 8); //左上から1行づつ走査していく long pt_dst = (i_t * s.w + i_l); long pt_src = pt_dst * 4 + (long)bm.Scan0; for (int y = i_h - 1; y >= 0; y -= 1) { int x; int p; for (x = pix_count - 1; x >= pix_mod_part; x--) { p = Marshal.ReadInt32((IntPtr)pt_src); output[pt_dst++] = (((p >> 16) & 0xff) + ((p >> 8) & 0xff) + (p & 0xff)) <= th ? 0 : 1; pt_src += 4; } for (; x >= 0; x -= 8) { Marshal.Copy((IntPtr)pt_src, work, 0, 32); output[pt_dst] = (work[0] + work[1] + work[2]) <= th ? 0 : 1; output[pt_dst + 1] = (work[4] + work[5] + work[6]) <= th ? 0 : 1; output[pt_dst + 2] = (work[8] + work[9] + work[10]) <= th ? 0 : 1; output[pt_dst + 3] = (work[12] + work[13] + work[14]) <= th ? 0 : 1; output[pt_dst + 4] = (work[16] + work[17] + work[18]) <= th ? 0 : 1; output[pt_dst + 5] = (work[20] + work[21] + work[22]) <= th ? 0 : 1; output[pt_dst + 6] = (work[24] + work[25] + work[26]) <= th ? 0 : 1; output[pt_dst + 7] = (work[28] + work[29] + work[30]) <= th ? 0 : 1; pt_src += 32; pt_dst += 8; } //スキップ pt_src += skip_src; pt_dst += skip_dst; } this._raster.unlockBitmap(); return; }
public override void doFilter(int i_l, int i_t, int i_w, int i_h, int i_th, INyARGrayscaleRaster i_gsraster) { Debug.Assert(i_gsraster.isEqualBufferType(NyARBufferType.INT1D_BIN_8)); short[] input = (short[])this._raster.getBuffer(); int[] output = (int[])i_gsraster.getBuffer(); int th = i_th * 3; NyARIntSize s = i_gsraster.getSize(); int skip_dst = (s.w - i_w); int skip_src = skip_dst; int pix_count = i_w; int pix_mod_part = pix_count - (pix_count % 8); //左上から1行づつ走査していく int pt_dst = (i_t * s.w + i_l); int pt_src = pt_dst; for (int y = i_h - 1; y >= 0; y -= 1) { int x, v; for (x = pix_count - 1; x >= pix_mod_part; x--) { v = (int)input[pt_src++]; output[pt_dst++] = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3)) <= th ? 0 : 1; } for (; x >= 0; x -= 8) { v = (int)input[pt_src++]; output[pt_dst++] = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3)) <= th ? 0 : 1; v = (int)input[pt_src++]; output[pt_dst++] = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3)) <= th ? 0 : 1; v = (int)input[pt_src++]; output[pt_dst++] = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3)) <= th ? 0 : 1; v = (int)input[pt_src++]; output[pt_dst++] = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3)) <= th ? 0 : 1; v = (int)input[pt_src++]; output[pt_dst++] = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3)) <= th ? 0 : 1; v = (int)input[pt_src++]; output[pt_dst++] = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3)) <= th ? 0 : 1; v = (int)input[pt_src++]; output[pt_dst++] = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3)) <= th ? 0 : 1; v = (int)input[pt_src++]; output[pt_dst++] = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3)) <= th ? 0 : 1; } //スキップ pt_src += skip_src; pt_dst += skip_dst; } return; }
public void doFilter(int i_l, int i_t, int i_w, int i_h, int i_th, INyARGrayscaleRaster i_gsraster) { Debug.Assert(i_gsraster.isEqualBufferType(NyARBufferType.INT1D_BIN_8)); BitmapData bm = this._raster.lockBitmap(); byte[] work = this._work; int[] output = (int[])i_gsraster.getBuffer(); NyARIntSize s = this._raster.getSize(); int th = i_th * 3; int skip_dst = (s.w - i_w); int skip_src = skip_dst * 4; int pix_count = i_w; int pix_mod_part = pix_count - (pix_count % 8); //左上から1行づつ走査していく int pt_dst = (i_t * s.w + i_l); int pt_src = pt_dst * 4+(int)bm.Scan0; for (int y = i_h - 1; y >= 0; y -= 1) { int x; int p; for (x = pix_count - 1; x >= pix_mod_part; x--) { p = Marshal.ReadInt32((IntPtr)pt_src); output[pt_dst++] = (((p >> 16) & 0xff) + ((p >> 8) & 0xff) + (p & 0xff)) <= th ? 0 : 1; pt_src += 4; } for (; x >= 0; x -= 8) { Marshal.Copy((IntPtr)pt_src, work, 0, 32); output[pt_dst ] = (work[0]+work[1]+work[2]) <= th ? 0 : 1; output[pt_dst+1] = (work[4] + work[5] + work[6]) <= th ? 0 : 1; output[pt_dst+2] = (work[8] + work[9] + work[10]) <= th ? 0 : 1; output[pt_dst+3] = (work[12] + work[13] + work[14]) <= th ? 0 : 1; output[pt_dst+4] = (work[16] + work[17] + work[18]) <= th ? 0 : 1; output[pt_dst+5] = (work[20] + work[21] + work[22]) <= th ? 0 : 1; output[pt_dst+6] = (work[24] + work[25] + work[26]) <= th ? 0 : 1; output[pt_dst+7] = (work[28] + work[29] + work[30]) <= th ? 0 : 1; pt_src += 32; pt_dst += 8; } //スキップ pt_src += skip_src; pt_dst += skip_dst; } this._raster.unlockBitmap(); return; }
public void doFilter(INyARGrayscaleRaster i_output) { Debug.Assert(i_output.isEqualBufferType(NyARBufferType.INT1D_GRAY_8)); NyARIntSize size = this._raster.getSize(); int[] in_ptr = (int[])this._raster.getBuffer(); switch (this._raster.getBufferType()) { case NyARBufferType.INT1D_GRAY_8: int[] out_ptr = (int[])i_output.getBuffer(); int width = size.w; int idx = 0; int idx2 = width; int fx, fy; int mod_p = (width - 2) - (width - 2) % 8; for (int y = size.h - 2; y >= 0; y--) { int p00 = in_ptr[idx++]; int p10 = in_ptr[idx2++]; int p01, p11; int x = width - 2; for (; x >= mod_p; x--) { p01 = in_ptr[idx++]; p11 = in_ptr[idx2++]; fx = p11 - p00; fy = p10 - p01; out_ptr[idx - 2] = ((fx < 0 ? -fx : fx) + (fy < 0 ? -fy : fy)) >> 1; p00 = p01; p10 = p11; } for (; x >= 0; x -= 4) { p01 = in_ptr[idx++]; p11 = in_ptr[idx2++]; fx = p11 - p00; fy = p10 - p01; out_ptr[idx - 2] = ((fx < 0 ? -fx : fx) + (fy < 0 ? -fy : fy)) >> 1; p00 = p01; p10 = p11; p01 = in_ptr[idx++]; p11 = in_ptr[idx2++]; fx = p11 - p00; fy = p10 - p01; out_ptr[idx - 2] = ((fx < 0 ? -fx : fx) + (fy < 0 ? -fy : fy)) >> 1; p00 = p01; p10 = p11; p01 = in_ptr[idx++]; p11 = in_ptr[idx2++]; fx = p11 - p00; fy = p10 - p01; out_ptr[idx - 2] = ((fx < 0 ? -fx : fx) + (fy < 0 ? -fy : fy)) >> 1; p00 = p01; p10 = p11; p01 = in_ptr[idx++]; p11 = in_ptr[idx2++]; fx = p11 - p00; fy = p10 - p01; out_ptr[idx - 2] = ((fx < 0 ? -fx : fx) + (fy < 0 ? -fy : fy)) >> 1; p00 = p01; p10 = p11; } out_ptr[idx - 1] = 0; } for (int x = width - 1; x >= 0; x--) { out_ptr[idx++] = 0; } return; default: //ANY未対応 throw new NyARException(); } }
public NyARGsGaussianSmoothFilter_GS8(INyARGrayscaleRaster i_raster) { Debug.Assert(i_raster.isEqualBufferType(NyARBufferType.INT1D_GRAY_8)); this._raster = i_raster; }
private void apply_filter(KpmImage dst, INyARGrayscaleRaster src) { Debug.Assert(src.isEqualBufferType(NyARBufferType.INT1D_GRAY_8)); binomial_4th_order((double[])dst.getBuffer(), this.mTemp_us16, (int[])src.getBuffer(), src.getWidth(), src.getHeight()); }