Ejemplo n.º 1
0
        /// <summary>
        /// Vectorizes the image as the numeric byte values of its pixels.
        /// The output vector is output in height then width major order, with the channels being the most minor (if
        /// <paramref name="interleaveArgb"/> is true) or major (if <paramref name="interleaveArgb"/> is false) dimension.
        /// </summary>
        /// <param name="input">The input image to extract</param>
        /// <param name="useAlpha">Whether the alpha channel should be extracted</param>
        /// <param name="useRed">Whether the red channel should be extracted</param>
        /// <param name="useGreen">Whether the green channel should be extracted</param>
        /// <param name="useBlue">Whether the blue channel should be extracted</param>
        /// <param name="interleaveArgb">Whether the pixel values should be interleaved, as opposed to being separated by channel</param>
        /// <returns>The vectorized image</returns>
        /// <seealso cref="ImagePixelExtractingEstimator"/>
        public static Vector <byte> ExtractPixelsAsBytes(this Custom <Bitmap> input, bool useAlpha = false, bool useRed = true,
                                                         bool useGreen = true, bool useBlue = true, bool interleaveArgb = false)
        {
            var colParams = new ImagePixelExtractorTransform.Column
            {
                UseAlpha       = useAlpha,
                UseRed         = useRed,
                UseGreen       = useGreen,
                UseBlue        = useBlue,
                InterleaveArgb = interleaveArgb,
                Convert        = false
            };

            return(new ImagePixelExtractingStaticExtensions.OutPipelineColumn <byte>(input, colParams));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Vectorizes the image as the numeric values of its pixels converted and possibly transformed to floating point values.
        /// The output vector is output in height then width major order, with the channels being the most minor (if
        /// <paramref name="interleaveArgb"/> is true) or major (if <paramref name="interleaveArgb"/> is false) dimension.
        /// </summary>
        /// <param name="input">The input image to extract</param>
        /// <param name="useAlpha">Whether the alpha channel should be extracted</param>
        /// <param name="useRed">Whether the red channel should be extracted</param>
        /// <param name="useGreen">Whether the green channel should be extracted</param>
        /// <param name="useBlue">Whether the blue channel should be extracted</param>
        /// <param name="interleaveArgb">Whether the pixel values should be interleaved, as opposed to being separated by channel</param>
        /// <param name="scale">Scale the normally 0 through 255 pixel values by this amount</param>
        /// <param name="offset">Add this amount to the pixel values, before scaling</param>
        /// <returns>The vectorized image</returns>
        /// <seealso cref="ImagePixelExtractingEstimator"/>
        public static Vector <float> ExtractPixels(this Custom <Bitmap> input, bool useAlpha = false, bool useRed = true,
                                                   bool useGreen = true, bool useBlue = true, bool interleaveArgb = false, float scale = 1.0f, float offset = 0.0f)
        {
            var colParams = new ImagePixelExtractorTransform.Column
            {
                UseAlpha       = useAlpha,
                UseRed         = useRed,
                UseGreen       = useGreen,
                UseBlue        = useBlue,
                InterleaveArgb = interleaveArgb,
                Scale          = scale,
                Offset         = offset,
                Convert        = true
            };

            return(new ImagePixelExtractingStaticExtensions.OutPipelineColumn <float>(input, colParams));
        }