public ImageSegmentator( Image2D <Color> image, ObjectBackgroundColorModels colorModels, double colorDifferencePairwiseTermCutoff, double colorDifferencePairwiseTermWeight, double constantPairwiseTermWeight, double objectColorUnaryTermWeight, double backgroundColorUnaryTermWeight, double objectShapeUnaryTermWeight, double backgroundShapeUnaryTermWeight) { if (image == null) { throw new ArgumentNullException("image"); } if (colorModels == null) { throw new ArgumentNullException("colorModels"); } if (colorDifferencePairwiseTermCutoff <= 0) { throw new ArgumentOutOfRangeException("colorDifferencePairwiseTermCutoff", "Parameter value should be positive."); } if (colorDifferencePairwiseTermWeight < 0) { throw new ArgumentOutOfRangeException("colorDifferencePairwiseTermWeight", "Parameter value should not be negative."); } if (constantPairwiseTermWeight < 0) { throw new ArgumentOutOfRangeException("constantPairwiseTermWeight", "Parameter value should not be negative."); } this.ColorDifferencePairwiseTermCutoff = colorDifferencePairwiseTermCutoff; this.ColorDifferencePairwiseTermWeight = colorDifferencePairwiseTermWeight; this.ConstantPairwiseTermWeight = constantPairwiseTermWeight; this.ObjectColorUnaryTermWeight = objectColorUnaryTermWeight; this.BackgroundColorUnaryTermWeight = backgroundColorUnaryTermWeight; this.ObjectShapeUnaryTermWeight = objectShapeUnaryTermWeight; this.BackgroundShapeUnaryTermWeight = backgroundShapeUnaryTermWeight; this.segmentedImage = image; this.UnaryTermScaleCoeff = 1.0 / (image.Width * image.Height); this.PairwiseTermScaleCoeff = 1.0 / Math.Sqrt(image.Width * image.Height); this.graphCutCalculator = new GraphCutCalculator(this.segmentedImage.Width, this.segmentedImage.Height); this.PrepareColorTerms(colorModels); this.PreparePairwiseTerms(); this.PrepareOther(); }
public ImageSegmentator( Image2D<Color> image, ObjectBackgroundColorModels colorModels, double colorDifferencePairwiseTermCutoff, double colorDifferencePairwiseTermWeight, double constantPairwiseTermWeight, double objectColorUnaryTermWeight, double backgroundColorUnaryTermWeight, double objectShapeUnaryTermWeight, double backgroundShapeUnaryTermWeight) { if (image == null) throw new ArgumentNullException("image"); if (colorModels == null) throw new ArgumentNullException("colorModels"); if (colorDifferencePairwiseTermCutoff <= 0) throw new ArgumentOutOfRangeException("colorDifferencePairwiseTermCutoff", "Parameter value should be positive."); if (colorDifferencePairwiseTermWeight < 0) throw new ArgumentOutOfRangeException("colorDifferencePairwiseTermWeight", "Parameter value should not be negative."); if (constantPairwiseTermWeight < 0) throw new ArgumentOutOfRangeException("constantPairwiseTermWeight", "Parameter value should not be negative."); this.ColorDifferencePairwiseTermCutoff = colorDifferencePairwiseTermCutoff; this.ColorDifferencePairwiseTermWeight = colorDifferencePairwiseTermWeight; this.ConstantPairwiseTermWeight = constantPairwiseTermWeight; this.ObjectColorUnaryTermWeight = objectColorUnaryTermWeight; this.BackgroundColorUnaryTermWeight = backgroundColorUnaryTermWeight; this.ObjectShapeUnaryTermWeight = objectShapeUnaryTermWeight; this.BackgroundShapeUnaryTermWeight = backgroundShapeUnaryTermWeight; this.segmentedImage = image; this.UnaryTermScaleCoeff = 1.0 / (image.Width * image.Height); this.PairwiseTermScaleCoeff = 1.0 / Math.Sqrt(image.Width * image.Height); this.graphCutCalculator = new GraphCutCalculator(this.segmentedImage.Width, this.segmentedImage.Height); this.PrepareColorTerms(colorModels); this.PreparePairwiseTerms(); this.PrepareOther(); }