Creates a kernel for the Haar wavelet "centered" around the target pixel.

@param r Radius of the box.  width is 2*r
@return Kernel for a Haar y-axis wavelet.
181855
public static IntegralKernel kernelHaarY( int r , IntegralKernel ret) {
		if( ret == null )
			ret = new IntegralKernel(2);

		ret.blocks[0].set(-r,-r,r,0);
		ret.blocks[1].set(-r,0,r,r);
		ret.scales[0] = -1;
		ret.scales[1] = 1;

		return ret;
	}
1261632
function (x, y, r) {
		var attr = isObject(x) ?
			x :
			{
				x: x,
				y: y,
				r: r
			};

		return this.createElement('circle').attr(attr);
	}
850965
public double computeConfidence( ImageRectangle r ) {
		return computeConfidence(r.x0,r.y0,r.x1,r.y1);
	}
923780
public static double gaussian() {
    // use the polar form of the Box-Muller transform
    double r, x, y;
    do {
      x = uniform(-1.0, 1.0);
      y = uniform(-1.0, 1.0);
      r = x * x + y * y;
    }
    while (r >= 1 || r == 0);
    return x * Math.sqrt(-2 * Math.log(r) / r);

    // Remark: y * Math.sqrt(-2 * Math.log(r) / r)
    // is an independent random gaussian
  }
518377
public static IntegralKernel kernelDerivX( int r , IntegralKernel ret ) {
		if( ret == null )
			ret = new IntegralKernel(2);

		ret.blocks[0].set(-r-1,-r-1,-1,r);
		ret.blocks[1].set(0,-r-1,r,r);
		ret.scales[0] = -1;
		ret.scales[1] = 1;

		return ret;
	}
1345552
def kernel(x1, x2, method='gaussian', sigma=1, **kwargs):
    """"""
    if method.lower() in ['gaussian', 'gauss', 'rbf']:
        K = np.exp(-dist(x1, x2) / (2 * sigma**2))
    return K
565055
public static void convolve(Kernel2D_F64 kernel, InterleavedF64 src, InterleavedF64 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 {
				if( Math.abs(kernel.computeSum() - 1.0f) > 1e-4f ) {
					Kernel2D_F64 k = kernel.copy();
					KernelMath.normalizeSumToOne(k);
					kernel = k;
				}
				ConvolveImageNoBorder.convolve(kernel,src,dst);
				ConvolveNormalized_JustBorder_IL.convolve(kernel,src,dst);
			}
		}
	}
941440
public static void horizontal(Kernel1D_S32 kernel, GrayU8 src, GrayI8 dst ) {
		InputSanityCheck.checkSameShape(src, dst);

		boolean processed = BOverrideConvolveImageNormalized.invokeNativeHorizontal(kernel,src,dst);
		
		if( !processed ) {
			if( kernel.width >= src.width ) {
				ConvolveNormalizedNaive_SB.horizontal(kernel, src, dst);
			} else {
				ConvolveImageNoBorder.horizontal(kernel, src, dst, kernel.computeSum());
				ConvolveNormalized_JustBorder_SB.horizontal(kernel, src, dst);
			}
		}
	}
226286
public ComplexPixel mult(double r, double i){
		double thisr = real(), thisi = imag();
		return setComplex(thisr*r-thisi*i, thisr*i+thisi*r);
	}
705357
public static void horizontal(Kernel1D_F64 kernel, GrayF64 src, GrayF64 dst ) {
		InputSanityCheck.checkSameShape(src, dst);

		boolean processed = BOverrideConvolveImageNormalized.invokeNativeHorizontal(kernel,src,dst);
		
		if( !processed ) {
			if( kernel.width >= src.width ) {
				ConvolveNormalizedNaive_SB.horizontal(kernel,src,dst);
			} else {
				if( Math.abs(kernel.computeSum() - 1.0f) > 1e-4f ) {
					Kernel1D_F64 k = kernel.copy();
					KernelMath.normalizeSumToOne(k);
					kernel = k;
				}
				ConvolveImageNoBorder.horizontal(kernel,src,dst);
				ConvolveNormalized_JustBorder_SB.horizontal(kernel,src,dst);
			}
		}
	}
469554
def ring(x, y, height, thickness, gaussian_width):
    
    radius = height/2.0
    half_thickness = thickness/2.0

    distance_from_origin = np.sqrt(x**2+y**2)
    distance_outside_outer_disk = distance_from_origin - radius - half_thickness
    distance_inside_inner_disk = radius - half_thickness - distance_from_origin

    ring = 1.0-np.bitwise_xor(np.greater_equal(distance_inside_inner_disk,0.0),
                              np.greater_equal(distance_outside_outer_disk,0.0))

    sigmasq = gaussian_width*gaussian_width

    if sigmasq==0.0:
        inner_falloff = x*0.0
        outer_falloff = x*0.0
    else:
        with float_error_ignore():
            inner_falloff = np.exp(np.divide(-distance_inside_inner_disk*distance_inside_inner_disk, 2.0*sigmasq))
            outer_falloff = np.exp(np.divide(-distance_outside_outer_disk*distance_outside_outer_disk, 2.0*sigmasq))

    return np.maximum(inner_falloff,np.maximum(outer_falloff,ring))
657380
public static Kernel1D_S32 table1D_I32(int radius) {
		Kernel1D_S32 ret = new Kernel1D_S32(radius * 2 + 1);

		for (int i = 0; i < ret.data.length; i++) {
			ret.data[i] = 1;
		}

		return ret;
	}
1025433
def kernel_pixelsize_change(kernel, deltaPix_in, deltaPix_out):
    
    numPix = len(kernel)
    numPix_new = int(round(numPix * deltaPix_in/deltaPix_out))
    if numPix_new % 2 == 0:
        numPix_new -= 1
    x_in = np.linspace(-(numPix-1)/2*deltaPix_in, (numPix-1)/2*deltaPix_in, numPix)
    x_out = np.linspace(-(numPix_new-1)/2*deltaPix_out, (numPix_new-1)/2*deltaPix_out, numPix_new)
    kernel_out = image_util.re_size_array(x_in, x_in, kernel, x_out, x_out)
    kernel_out = kernel_norm(kernel_out)
    return kernel_out
1356047
public static double[] gaussianSmooth( double[] values, int kernelRadius ) throws Exception {
        int size = values.length;
        double[] newValues = new double[values.length];
        double[] kernelData2D = makeGaussianKernel(kernelRadius);
        for( int i = 0; i < kernelRadius; i++ ) {
            newValues[i] = values[i];
        }
        for( int r = kernelRadius; r < size - kernelRadius; r++ ) {
            double kernelSum = 0.0;
            double outputValue = 0.0;
            int k = 0;
            for( int kc = -kernelRadius; kc <= kernelRadius; kc++, k++ ) {
                double value = values[r + kc];
                if (!isNovalue(value)) {
                    outputValue = outputValue + value * kernelData2D[k];
                    kernelSum = kernelSum + kernelData2D[k];
                }
            }
            newValues[r] = outputValue / kernelSum;
        }
        for( int i = size - kernelRadius; i < size; i++ ) {
            newValues[i] = values[i];
        }
        return newValues;
    }
967082
public void circle(float x, float y, float r) {
        float b = 0.5523f;
        moveTo(x + r, y);
        curveTo(x + r, y + r * b, x + r * b, y + r, x, y + r);
        curveTo(x - r * b, y + r, x - r, y + r * b, x - r, y);
        curveTo(x - r, y - r * b, x - r * b, y - r, x, y - r);
        curveTo(x + r * b, y - r, x + r, y - r * b, x + r, y);
    }
637382
public GridCoverage2D buildRaster() {
        if (makeNew) {
            GridCoverage2D coverage = buildCoverage("raster", newWR, regionMap, crs);
            return coverage;
        } else {
            throw new RuntimeException("The raster is readonly, so no new raster can be built.");
        }
    }
913529
def make_gaussian_kernel(sigma, npix=501, cdelt=0.01, xpix=None, ypix=None):
    

    sigma /= cdelt

    def fn(t, s): return 1. / (2 * np.pi * s ** 2) * np.exp(
        -t ** 2 / (s ** 2 * 2.0))
    dxy = make_pixel_distance(npix, xpix, ypix)
    k = fn(dxy, sigma)
    k /= (np.sum(k) * np.radians(cdelt) ** 2)

    return k