Performs a horizontal 1D normalized convolution across the image.

@param src The original image. Not modified.
@param dst Where the resulting image is written to. Modified.
@param kernel The kernel that is being convolved. Not modified.
15699
public static void horizontal(Kernel1D_F32 kernel, InterleavedF32 src, InterleavedF32 dst ) {
		InputSanityCheck.checkSameShapeB(src, dst);

		boolean processed = BOverrideConvolveImageNormalized.invokeNativeHorizontal(kernel,src,dst);
		
		if( !processed ) {
			if( kernel.width >= src.width ) {
				ConvolveNormalizedNaive_IL.horizontal(kernel,src,dst);
			} else {
				if( Math.abs(kernel.computeSum() - 1.0f) > 1e-4f ) {
					Kernel1D_F32 k = kernel.copy();
					KernelMath.normalizeSumToOne(k);
					kernel = k;
				}
				ConvolveImageNoBorder.horizontal(kernel,src,dst);
				ConvolveNormalized_JustBorder_IL.horizontal(kernel,src,dst);
			}
		}
	}
666687
public static void horizontal( GrayF32 src , GrayF32 dst ) {

		if( src.width < dst.width )
			throw new IllegalArgumentException("src width must be >= dst width");
		if( src.height != dst.height )
			throw new IllegalArgumentException("src height must equal dst height");

		float scale = src.width/(float)dst.width;

		//CONCURRENT_BELOW BoofConcurrency.loopFor(0, dst.height, y -> {
		for (int y = 0; y < dst.height; y++) {
			int indexDst = dst.startIndex + y*dst.stride;
			for (int x = 0; x < dst.width-1; x++, indexDst++ ) {
				float srcX0 = x*scale;
				float srcX1 = (x+1)*scale;

				int isrcX0 = (int)srcX0;
				int isrcX1 = (int)srcX1;

				int index = src.getIndex(isrcX0,y);

				// compute value of overlapped region
				float startWeight = (1.0f-(srcX0-isrcX0));
				float start = src.data[index++];

				float middle = 0;
				for( int i = isrcX0+1; i < isrcX1; i++ ) {
					middle += src.data[index++];
				}

				float endWeight = (srcX1%1);
				float end = src.data[index];
				dst.data[indexDst] = (start*startWeight + middle + end*endWeight)/scale;
			}

			// handle the last area as a special case
			int x = dst.width-1;
			float srcX0 = x*scale;

			int isrcX0 = (int)srcX0;
			int isrcX1 = src.width-1;

			int index = src.getIndex(isrcX0,y);

			// compute value of overlapped region
			float startWeight = (1.0f-(srcX0-isrcX0));
			float start = src.data[index++];

			float middle = 0;
			for( int i = isrcX0+1; i < isrcX1; i++ ) {
				middle += src.data[index++];
			}

			float end = isrcX1 != isrcX0 ? src.data[index] : 0;
			dst.data[indexDst] = (start*startWeight + middle + end)/scale;
		}
		//CONCURRENT_ABOVE });
	}
1370960
private static void convolve1D(GrayU8 gray) {
		ImageBorder<GrayU8> border = FactoryImageBorder.wrap(BorderType.EXTENDED, gray);
		Kernel1D_S32 kernel = new Kernel1D_S32(2);
		kernel.offset = 1; // specify the kernel's origin
		kernel.data[0] = 1;
		kernel.data[1] = -1;

		GrayS16 output = new GrayS16(gray.width,gray.height);

		GConvolveImageOps.horizontal(kernel, gray, output, border);
		panel.addImage(VisualizeImageData.standard(output, null), "1D Horizontal");

		GConvolveImageOps.vertical(kernel, gray, output, border);
		panel.addImage(VisualizeImageData.standard(output, null), "1D Vertical");
	}
484198
private void process(int[] srcImage, int[] dstImage, int x, int y)
    {
        final int a = getSourcePixel(srcImage, x - 1, y - 1);
        final int b = getSourcePixel(srcImage, x, y - 1);
        final int c = getSourcePixel(srcImage, x + 1, y - 1);
        final int d = getSourcePixel(srcImage, x - 1, y);
        final int e = getSourcePixel(srcImage, x, y);
        final int f = getSourcePixel(srcImage, x + 1, y);
        final int g = getSourcePixel(srcImage, x - 1, y + 1);
        final int h = getSourcePixel(srcImage, x, y + 1);
        final int i = getSourcePixel(srcImage, x + 1, y + 1);
        int e0 = e;
        int e1 = e;
        int e2 = e;
        int e3 = e;
        int e4 = e;
        int e5 = e;
        int e6 = e;
        int e7 = e;
        int e8 = e;

        if (b != h && d != f)
        {
            e0 = computeE0(b, d, e);
            e1 = computeE1(a, b, c, d, e, f);
            e2 = computeE2(b, e, f);
            e3 = computeE3(a, b, d, e, g, h);
            e4 = e;
            e5 = computeE5(b, c, e, f, h, i);
            e6 = computeE6(d, e, h);
            e7 = computeE7(d, e, f, g, h, i);
            e8 = computeE8(e, f, h);
        }

        setDestPixel(dstImage, x * SCALE, y * SCALE, e0);
        setDestPixel(dstImage, x * SCALE + 1, y * SCALE, e1);
        setDestPixel(dstImage, x * SCALE + 2, y * SCALE, e2);
        setDestPixel(dstImage, x * SCALE, y * SCALE + 1, e3);
        setDestPixel(dstImage, x * SCALE + 1, y * SCALE + 1, e4);
        setDestPixel(dstImage, x * SCALE + 2, y * SCALE + 1, e5);
        setDestPixel(dstImage, x * SCALE, y * SCALE + 2, e6);
        setDestPixel(dstImage, x * SCALE + 1, y * SCALE + 2, e7);
        setDestPixel(dstImage, x * SCALE + 2, y * SCALE + 2, e8);
    }
1280554
private static void convolve2D(GrayU8 gray) {
		// By default 2D kernels will be centered around width/2
		Kernel2D_S32 kernel = new Kernel2D_S32(3);
		kernel.set(1,0,2);
		kernel.set(2,1,2);
		kernel.set(0,1,-2);
		kernel.set(1,2,-2);

		// Output needs to handle the increased domain after convolution.  Can't be 8bit
		GrayS16 output = new GrayS16(gray.width,gray.height);
		ImageBorder<GrayU8> border = FactoryImageBorder.wrap( BorderType.EXTENDED,gray);

		GConvolveImageOps.convolve(kernel, gray, output, border);
		panel.addImage(VisualizeImageData.standard(output, null), "2D Kernel");
	}
383530
public static void bufferedToGray(DataBufferByte buffer, WritableRaster src, GrayF32 dst) {
		byte[] srcData = buffer.getData();

		int numBands = src.getNumBands();

		int srcStride = stride(src);
		int srcOffset = getOffset(src);

		if(BoofConcurrency.USE_CONCURRENT ) {
			if (numBands == 3) {
				ImplConvertRaster_MT.from_3BU8_to_F32(srcData, srcStride, srcOffset, dst);
			} else if (numBands == 1) {
				ImplConvertRaster_MT.from_1BU8_to_F32(srcData, srcStride, srcOffset, dst);
			} else if (numBands == 4) {
				ImplConvertRaster_MT.from_4BU8_to_F32(srcData, srcStride, srcOffset, dst);
			} else {
				throw new RuntimeException("Write more code here.");
			}
		} else {
			if (numBands == 3) {
				ImplConvertRaster.from_3BU8_to_F32(srcData, srcStride, srcOffset, dst);
			} else if (numBands == 1) {
				ImplConvertRaster.from_1BU8_to_F32(srcData, srcStride, srcOffset, dst);
			} else if (numBands == 4) {
				ImplConvertRaster.from_4BU8_to_F32(srcData, srcStride, srcOffset, dst);
			} else {
				throw new RuntimeException("Write more code here.");
			}
		}
	}
684377
public static void convolve(Kernel2D_S32 kernel, GrayS16 src, GrayI16 dst ) {
		InputSanityCheck.checkSameShape(src, dst);

		boolean processed = BOverrideConvolveImageNormalized.invokeNativeConvolve(kernel,src,dst);
		
		if( !processed ) {
			if( kernel.width >= src.width || kernel.width >= src.height ) {
				ConvolveNormalizedNaive_SB.convolve(kernel, src, dst);
			} else {
				ConvolveImageNoBorder.convolve(kernel, src, dst, kernel.computeSum(), null);
				ConvolveNormalized_JustBorder_SB.convolve(kernel, src, dst);
			}
		}
	}
121610
@Override
	public void compute(float x, float y, Point2D_F32 out) {
		float sum = 0;

		float radial[] = params.radial;
		float t1 = params.t1, t2 = params.t2;

		// out is undistorted normalized image coordinate
		out.x = a11*x + a12*y + a13;
		out.y = a22*y + a23;

		float r2 = out.x * out.x + out.y * out.y;
		float ri2 = r2;

		for (int i = 0; i < radial.length; i++) {
			sum += radial[i] * ri2;
			ri2 *= r2;
		}

		float tx = 2 * t1 * out.x * out.y + t2 * (r2 + 2 * out.x * out.x);
		float ty = t1 * (r2 + 2 * out.y * out.y) + 2 * t2 * out.x * out.y;

		// now compute the distorted normalized image coordinate
		out.x = out.x*(1 + sum) + tx;
		out.y = out.y*(1 + sum) + ty;
	}
539438
public static void convolve(Kernel2D_S32 kernel, InterleavedS32 src, InterleavedS32 dst ) {
		InputSanityCheck.checkSameShapeB(src, dst);

		boolean processed = BOverrideConvolveImageNormalized.invokeNativeConvolve(kernel,src,dst);
		
		if( !processed ) {
			if( kernel.width >= src.width || kernel.width >= src.height ) {
				ConvolveNormalizedNaive_IL.convolve(kernel, src, dst);
			} else {
				ConvolveImageNoBorder.convolve(kernel, src, dst, kernel.computeSum());
				ConvolveNormalized_JustBorder_IL.convolve(kernel, src, dst);
			}
		}
	}
1165538
public static void extract(DMatrixRMaj src, int indexes[] , int length , DMatrixRMaj dst ) {
        if( !MatrixFeatures_DDRM.isVector(dst))
            throw new MatrixDimensionException("Dst must be a vector");
        if( length != dst.getNumElements())
            throw new MatrixDimensionException("Unexpected number of elements in dst vector");

        for (int i = 0; i < length; i++) {
            dst.data[i] = src.data[indexes[i]];
        }
    }
808502
def reorder_image(dst_order, src_arr, src_order):
    
    depth = src_arr.shape[2]
    if depth != len(src_order):
        raise ValueError("src_order (%s) does not match array depth (%d)" % (
            src_order, depth))

    bands = []
    if dst_order == src_order:
        return np.ascontiguousarray(src_arr)

    elif 'A' not in dst_order or 'A' in src_order:
        # <-- we don't have to add an alpha plane, just create a new view
        idx = np.array([src_order.index(c) for c in dst_order])
        return np.ascontiguousarray(src_arr[..., idx])

    else:
        # <-- dst order requires missing alpha channel
        indexes = [src_order.index(c) for c in dst_order.replace('A', '')]
        bands = [src_arr[..., idx, np.newaxis] for idx in indexes]
        ht, wd = src_arr.shape[:2]
        dst_type = src_arr.dtype
        dst_max_val = np.iinfo(dst_type).max
        alpha = np.full((ht, wd, 1), dst_max_val, dtype=dst_type)
        bands.insert(dst_order.index('A'), alpha)

    return np.concatenate(bands, axis=-1)
1236519
public static void horizontal(GrayF32 input, GrayF32 output, int radius) {
		InputSanityCheck.checkSameShape(input , output);

		Kernel1D_F32 kernel = FactoryKernel.table1D_F32(radius,false);
		ConvolveJustBorder_General_SB.horizontal(kernel,ImageBorderValue.wrap(input,0),output);
		if(BoofConcurrency.USE_CONCURRENT ) {
			ImplConvolveBox_MT.horizontal(input, output, radius);
		} else {
			ImplConvolveBox.horizontal(input, output, radius);
		}
	}
1129331
public static function &override(&$dst, $src) {
        foreach ($src as $key => $value) {
            if (!array_key_exists($key, $dst)) {
                $dst[$key] = $value;
            } else if (is_array($value) && is_array($dst[$key])) {
                if (self::isIndexedArray($dst[$key])) {
                    $dst[$key] = $value;
                } else {
                    self::override($dst[$key], $value);
                }
            } else if (is_int($key)) {
                $dst[] = $value;
            } else {
                $dst[$key] = $value;
            }
        }
        return $dst;
    }
976325
public final void fmul(X87Register dst, X87Register src)
  {
    assert(dst.index() == 0 || src.index() == 0);
    emitX86(INST_FMUL, dst, src);
  }
1314421
public static void convolve(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, int edgeAction) {
		convolve(kernel, inPixels, outPixels, width, height, true, edgeAction);
	}
1078489
public final void movbe(Register dst, Mem src)
  {
    assert(!dst.isRegType(REG_GPB));
    emitX86(INST_MOVBE, dst, src);
  }
402452
public static void vertical(Kernel1D_S32 kernel, GrayS16 src, GrayI16 dst ) {
		InputSanityCheck.checkSameShape(src, dst);

		boolean processed = BOverrideConvolveImageNormalized.invokeNativeVertical(kernel,src,dst);
		
		if( !processed ) {
			if( kernel.width >= src.height ) {
				ConvolveNormalizedNaive_SB.vertical(kernel, src, dst);
			} else {
				ConvolveImageNoBorder.vertical(kernel, src, dst, kernel.computeSum());
				ConvolveNormalized_JustBorder_SB.vertical(kernel, src, dst);
			}
		}
	}