/// <summary> /// Creates template from the input image by using provided parameters. /// </summary> /// <param name="sourceImage">Input image.</param> /// <param name="minFeatureStrength">Minimum gradient value for the feature.</param> /// <param name="maxNumberOfFeatures">Maximum number of features per template. The features will be extracted so that their locations are semi-uniformly spread.</param> /// <param name="classLabel">Template class label.</param> public override void Initialize(Gray<byte>[,] sourceImage, int minFeatureStrength, int maxNumberOfFeatures, string classLabel) { base.Initialize(sourceImage, minFeatureStrength, maxNumberOfFeatures, classLabel); this.BinaryMask = sourceImage.Clone(BoundingRect); if (this.BinaryMask[0, 0].Intensity != 0) //background should be black BinaryMask = this.BinaryMask.Not(); this.BinaryMask = this.BinaryMask.ThresholdToZero((byte)(255 * 0.75), (byte)255); //if Gauss kernel was applied... }