Mean-shift based search with a uniform kernel
@param maxIterations Maximum number of iterations.  Try 15
@param convergenceTol Convergence tolerance.  try 1e-3
@param imageType Type of input image
@return mean-shift search
187200
public static <T extends ImageGray<T>>
	SearchLocalPeak<T> meanShiftUniform( int maxIterations, float convergenceTol , Class<T> imageType ) {
		WeightPixel_F32 weights = new WeightPixelUniform_F32();
		MeanShiftPeak<T> alg = new MeanShiftPeak<>(maxIterations, convergenceTol, weights, imageType);
		return new MeanShiftPeak_to_SearchLocalPeak<>(alg);
	}
62675
protected int score(MediaType contentTypeFromRequest, MediaType... expectedTypes) {
        if (contentTypeFromRequest == null) {
            return DEFAULT_SCORE;
        }
        for (MediaType expected : expectedTypes) {
            if (contentTypeFromRequest.matches(expected)) {
                return MAXIMUM_FORMAT_SCORE;
            }
        }
        return DEFAULT_SCORE;
    }
621631
public static KernelBase lookupKernelX( DerivativeType type , boolean isInteger) {
		switch( type ) {
			case PREWITT:
				return GradientPrewitt.getKernelX(isInteger);

			case SOBEL:
				return GradientSobel.getKernelX(isInteger);

			case THREE:
				return GradientThree.getKernelX(isInteger);

			case TWO_0:
				return GradientTwo0.getKernelX(isInteger);

			case TWO_1:
				return GradientTwo1.getKernelX(isInteger);
		}

		throw new IllegalArgumentException("Unknown kernel type: "+type);
	}
1167198
private boolean limitScale(
      Matrix transform,
      float pivotX,
      float pivotY,
      @LimitFlag int limitTypes) {
    if (!shouldLimit(limitTypes, LIMIT_SCALE)) {
      return false;
    }
    float currentScale = getMatrixScaleFactor(transform);
    float targetScale = limit(currentScale, mMinScaleFactor, mMaxScaleFactor);
    if (targetScale != currentScale) {
      float scale = targetScale / currentScale;
      transform.postScale(scale, scale, pivotX, pivotY);
      return true;
    }
    return false;
  }
957170
public void setTo( ImageType o ) {
		this.family = o.family;
		this.dataType = o.dataType;
		this.numBands = o.numBands;
	}
1211065
def suits_with_dtype(mn, mx, dtype):
    
    type_info = np.iinfo(dtype)
    if mx <= type_info.max and mn >= type_info.min:
        return True
    else:
        return False
63092
@Override
    public Object getParameterType(String name) {
        if ("maxIterations".equals(name)) return Integer.MAX_VALUE;
        return null;
    }
500237
def _getMinMax(img):
    '''
    
    '''
    av = np.mean(img)
    std = np.std(img)
    # define range for segmentation:
    mn = av - 3 * std
    mx = av + 3 * std

    return max(img.min(), mn, 0), min(img.max(), mx)
195617
public double maxDist(SpatialComparable mbr1, SpatialComparable mbr2) {
    final int dim1 = mbr1.getDimensionality(), dim2 = mbr2.getDimensionality();
    final int mindim = dim1 < dim2 ? dim1 : dim2;

    double agg = 0.;
    for(int d = 0; d < mindim; d++) {
      double d1 = mbr1.getMax(d) - mbr2.getMin(d);
      double d2 = mbr2.getMax(d) - mbr1.getMin(d);
      double delta = d1 > d2 ? d1 : d2;
      agg += delta * delta;
    }
    for(int d = mindim; d < dim1; d++) {
      double d1 = Math.abs(mbr1.getMin(d)), d2 = Math.abs(mbr1.getMax(d));
      double delta = d1 > d2 ? d1 : d2;
      agg += delta * delta;
    }
    for(int d = mindim; d < dim2; d++) {
      double d1 = Math.abs(mbr2.getMin(d)), d2 = Math.abs(mbr2.getMax(d));
      double delta = d1 > d2 ? d1 : d2;
      agg += delta * delta;
    }
    return FastMath.sqrt(agg);
  }
17961
private static int getScaleFactor(ImageMetadata metadata, int maxPixels) {
        int scale = 1;
        int scaledW = metadata.getW();
        int scaledH = metadata.getH();
        while (scaledW * scaledH > maxPixels) {
            scale *= 2;
            scaledH /= 2;
            scaledW /= 2;
        }
        return scale;
    }
893548
public static <T> T max(T lhs, T rhs, Comparator<T> comparator) {
        return BinaryOperator.maxBy(comparator).apply(lhs, rhs);
    }
268166
public void setImplicitConvergenceCriterion(String aggregatorName, ConvergenceCriterion<?> convCriterion) {
		try {
			InstantiationUtil.writeObjectToConfig(convCriterion, this.config, ITERATION_IMPLICIT_CONVERGENCE_CRITERION);
		} catch (IOException e) {
			throw new RuntimeException("Error while writing the implicit convergence criterion object to the task configuration.");
		}
		this.config.setString(ITERATION_IMPLICIT_CONVERGENCE_CRITERION_AGG_NAME, aggregatorName);
	}
1237467
public DataPoint type(Type type) {
        if (this.type != type) {
            this.type = type;
            switch (type) {
            case AVERAGE:
            case SUM:
                this.value = 0;
                break;
            case MAXIMUM:
                this.value = Long.MIN_VALUE;
                break;
            case MINIMUM:
                this.value = Long.MAX_VALUE;
                break;
            default:
                this.value = 0;
                break;
            }
            this.numPoints = 0;
        }
        return this;
    }
1078260
public void setMaxIn( double max ) {
    long imax = Double.doubleToRawLongBits(max);
    double old = _maxIn;
    while( max > old && !_unsafe.compareAndSwapLong(this, _max2Offset, Double.doubleToRawLongBits(old), imax ) )
      old = _maxIn;
  }
330274
public static <T extends ImageBase<T>>
	BackgroundStationaryGaussian<T> stationaryGaussian(@Nonnull ConfigBackgroundGaussian config , ImageType<T> imageType ) {

		config.checkValidity();

		BackgroundStationaryGaussian<T> ret;

		switch( imageType.getFamily() ) {
			case GRAY:
				ret = new BackgroundStationaryGaussian_SB(config.learnRate,config.threshold,imageType.getImageClass());
				break;

			case PLANAR:
				ret =  new BackgroundStationaryGaussian_PL(config.learnRate,config.threshold,imageType);
				break;

			case INTERLEAVED:
				ret =  new BackgroundStationaryGaussian_IL(config.learnRate,config.threshold,imageType);
				break;

			default:
				throw new IllegalArgumentException("Unknown image type");
		}

		ret.setInitialVariance(config.initialVariance);
		ret.setMinimumDifference(config.minimumDifference);
		ret.setUnknownValue(config.unknownValue);

		return ret;
	}
787701
public static Specification<JpaDistributionSet> byType(final DistributionSetType type) {
        return (targetRoot, query, cb) -> cb.equal(targetRoot.<JpaDistributionSetType> get(JpaDistributionSet_.type),
                type);

    }
746011
public static <T extends ImageBase<T>>
	ComputeRegionMeanColor<T> regionMeanColor(ImageType<T> imageType) {
		if( imageType.getFamily() == ImageType.Family.GRAY) {
			switch( imageType.getDataType() ) {
				case U8:
					return (ComputeRegionMeanColor)new ComputeRegionMeanColor.U8();
				case F32:
					return (ComputeRegionMeanColor)new ComputeRegionMeanColor.F32();
			}
		} else if( imageType.getFamily() == ImageType.Family.PLANAR) {
			int N = imageType.getNumBands();
			switch( imageType.getDataType() ) {
				case U8:
					return (ComputeRegionMeanColor)new ComputeRegionMeanColor.PL_U8(N);
				case F32:
					return (ComputeRegionMeanColor)new ComputeRegionMeanColor.PL_F32(N);
			}
		}

		throw new IllegalArgumentException("Unknown imageType");
	}