Exemplo n.º 1
0
        public void EntropyCropThresholdFloatEntropyCropProcessorWithThreshold(float threshold)
        {
            this.operations.EntropyCrop(threshold);
            EntropyCropProcessor processor = this.Verify <EntropyCropProcessor>();

            Assert.Equal(threshold, processor.Threshold);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Crops an image to the area of greatest entropy.
        /// </summary>
        /// <typeparam name="TColor">The pixel format.</typeparam>
        /// <param name="source">The image to crop.</param>
        /// <param name="threshold">The threshold for entropic density.</param>
        /// <returns>The <see cref="Image"/></returns>
        public static Image <TColor> EntropyCrop <TColor>(this Image <TColor> source, float threshold = .5f)
            where TColor : struct, IPackedPixel, IEquatable <TColor>
        {
            EntropyCropProcessor <TColor> processor = new EntropyCropProcessor <TColor>(threshold);

            return(source.Apply(source.Bounds, processor));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Crops an image to the area of greatest entropy.
        /// </summary>
        /// <typeparam name="TColor">The pixel format.</typeparam>
        /// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
        /// <param name="source">The image to crop.</param>
        /// <param name="threshold">The threshold for entropic density.</param>
        /// <returns>The <see cref="Image"/></returns>
        public static Image <TColor, TPacked> EntropyCrop <TColor, TPacked>(this Image <TColor, TPacked> source, float threshold = .5f)
            where TColor : struct, IPackedPixel <TPacked>
            where TPacked : struct, IEquatable <TPacked>
        {
            EntropyCropProcessor <TColor, TPacked> processor = new EntropyCropProcessor <TColor, TPacked>(threshold);

            return(source.Process(source.Bounds, processor));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Crops an image to the area of greatest entropy.
        /// </summary>
        /// <typeparam name="TPixel">The pixel format.</typeparam>
        /// <param name="source">The image to crop.</param>
        /// <param name="threshold">The threshold for entropic density.</param>
        /// <returns>The <see cref="Image"/></returns>
        public static Image <TPixel> EntropyCrop <TPixel>(this Image <TPixel> source, float threshold = .5f)
            where TPixel : struct, IPixel <TPixel>
        {
            EntropyCropProcessor <TPixel> processor = new EntropyCropProcessor <TPixel>(threshold);

            source.ApplyProcessor(processor, source.Bounds);
            return(source);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Crops an image to the area of greatest entropy.
        /// </summary>
        /// <typeparam name="TColor">The pixel format.</typeparam>
        /// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
        /// <param name="source">The image to crop.</param>
        /// <param name="threshold">The threshold for entropic density.</param>
        /// <returns>The <see cref="Image"/></returns>
        public static Image <TColor, TPacked> EntropyCrop <TColor, TPacked>(this Image <TColor, TPacked> source, float threshold = .5f)
            where TColor : struct, IPackedPixel <TPacked>
            where TPacked : struct
        {
            EntropyCropProcessor <TColor, TPacked> processor = new EntropyCropProcessor <TColor, TPacked>(threshold);

            return(source.Process(source.Width, source.Height, source.Bounds, Rectangle.Empty, processor));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Crops an image to the area of greatest entropy.
        /// </summary>
        /// <typeparam name="T">The pixel format.</typeparam>
        /// <typeparam name="TP">The packed format. <example>long, float.</example></typeparam>
        /// <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 <T, TP> EntropyCrop <T, TP>(this Image <T, TP> source, float threshold = .5f, ProgressEventHandler progressHandler = null)
            where T : IPackedVector <TP>
            where TP : struct
        {
            EntropyCropProcessor <T, TP> processor = new EntropyCropProcessor <T, TP>(threshold);

            processor.OnProgress += progressHandler;

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