Esempio n. 1
0
        /// <summary>
        /// Creates a comic rendered copy of the input image.
        /// </summary>
        public override Bitmap Render(Bitmap sourceImage)
        {
            GrayscaleToRGB convertColor = new GrayscaleToRGB();

            if (sourceImage.PixelFormat == PixelFormat.Format8bppIndexed)
            {
                sourceImage = convertColor.Apply(sourceImage);
            }

            BilateralBlur blur  = new BilateralBlur(3, 0.1);
            Bitmap        comic = blur.Apply(sourceImage);

            // Edges
            Bitmap            grayscale = Grayscale.CommonAlgorithms.Y.Apply(comic);
            SobelEdgeDetector sobelEdge = new SobelEdgeDetector();

            sobelEdge.ScaleIntensity = true;
            Bitmap edgeLayer = sobelEdge.Apply(grayscale);

            edgeLayer = convertColor.Apply(edgeLayer);

            Invert invertEdge = new Invert();

            invertEdge.ApplyInPlace(edgeLayer);

            HSLLinear edgeLinear = new HSLLinear();

            edgeLinear.InLuminance.Min = 0;
            edgeLinear.InLuminance.Max = 0.8;
            edgeLinear.ApplyInPlace(edgeLayer);


            // highlights
            Bitmap     highlightLayer      = invertEdge.Apply(edgeLayer);
            Dilatation highlightDilitation = new Dilatation();

            highlightDilitation.ApplyInPlace(highlightLayer);

            BrightnessCorrection highlightBright = new BrightnessCorrection(-0.35);

            highlightBright.ApplyInPlace(highlightLayer);
            ColorDodge highlightBlend = new ColorDodge(highlightLayer);

            highlightBlend.ApplyInPlace(comic);


            // Merge edges with working layer
            Multiply multEdge = new Multiply(edgeLayer);

            multEdge.ApplyInPlace(comic);


            return(comic);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a comic rendered copy of the input image.
        /// </summary>
        public override Bitmap Render(Bitmap sourceImage)
        {
            Bitmap sketchImage = AForge.Imaging.Image.Clone(sourceImage);

            GrayscaleY convertGray = new GrayscaleY();

            // Blur
            GaussianBlur filterBlur = new GaussianBlur();

            filterBlur.Sigma = this.PencilTipSize;
            filterBlur.Size  = this.PencilTipSize;
            Bitmap overLayer = filterBlur.Apply(sketchImage);

            // Invert over layer
            Invert sketchInvert = new Invert();

            sketchInvert.ApplyInPlace(overLayer);

            BrightnessCorrection filterBrightness = new BrightnessCorrection(-this.Range * 0.01);

            filterBrightness.ApplyInPlace(overLayer);

            ContrastCorrection filterContrast = new ContrastCorrection(1 - (-this.Range * 0.01));

            filterContrast.ApplyInPlace(overLayer);

            // Convert to grayscale
            sketchImage = convertGray.Apply(sketchImage);
            overLayer   = convertGray.Apply(overLayer);

            // Dodge blending for the win!
            ColorDodge dodgeBlend = new ColorDodge(overLayer);

            dodgeBlend.ApplyInPlace(sketchImage);

            return(sketchImage);
        }
 DEFINE_STANDARD_OP(ColorDodge, COLORDODGE)