Exemplo n.º 1
0
        // public ImageFactory DetectObjects(HaarCascade cascade, bool drawRectangles = true, Color color = default(Color))
        // {
        //    if (this.ShouldProcess)
        //    {
        //        DetectObjects detectObjects = new DetectObjects { DynamicParameter = cascade };
        //        this.CurrentImageFormat.ApplyProcessor(detectObjects.ProcessImage, this);
        //    }
        //     return this;
        // }

        /// <summary>
        /// Crops an image to the area of greatest entropy.
        /// </summary>
        /// <param name="threshold">
        /// The threshold in bytes to control the entropy.
        /// </param>
        /// <returns>
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public ImageFactory EntropyCrop(byte threshold = 128)
        {
            if (this.ShouldProcess)
            {
                EntropyCrop autoCrop = new EntropyCrop {
                    DynamicParameter = threshold
                };
                this.CurrentImageFormat.ApplyProcessor(autoCrop.ProcessImage, this);
            }

            return(this);
        }
        /// <summary>
        /// Crops an image to the area of greatest entropy.
        /// </summary>
        /// <param name="source">The image to crop.</param>
        /// <param name="threshold">The threshold for entropic density.</param>
        /// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
        /// <returns>The <see cref="Image"/></returns>
        public static Image EntropyCrop(this Image source, float threshold = .5f, ProgressEventHandler progressHandler = null)
        {
            EntropyCrop processor = new EntropyCrop(threshold);
            processor.OnProgress += progressHandler;

            try
            {
                return source.Process(source.Width, source.Height, source.Bounds, source.Bounds, processor);
            }
            finally
            {
                processor.OnProgress -= progressHandler;
            }
        }