Image Filter Art---(Sketch filter) sketch Filter

Source: Internet
Author: User
Tags image filter

(Sketch filter) sketch Filter

Sketch Filter Implementation method is relatively simple, here we directly write the algorithm process is as follows:

1, the original s for the de-color command to get the grayscale image A;

2, the inverse color of a to get the image B;

3, Gaussian Blur to B is obtained figure C;

4, the layer blending algorithm of C and B for color Dodge:

P (x, y) = PB (x, y) + (Pb (x, y) * Pc (x, Y))/(256-PC (x, y));

In step 3, you can add variable edgeintensity (edgeintensity>=0) to control the edge strength of the sketch;

The above is the algorithm implementation of the sketch.

The core code is as follows:

Private Bitmap sketchfilterprocess (Bitmap src, int. edgeintensity)
{
Bitmap Gaussbitmap = GF. Apply (SRC, edgeintensity);
Bitmap DST = new Bitmap (SRC);
int w = DST. Width;
int h = DST. Height;
BitmapData Dstdata = DST. LockBits (New Rectangle (0, 0, W, h), Imagelockmode.readwrite, Pixelformat.format32bppargb);
BitmapData edgedata = gaussbitmap.lockbits (new Rectangle (0, 0, W, h), Imagelockmode.readonly, PIXELFORMAT.FORMAT32BPPARGB);
byte* Pgauss = (byte*) edgedata.scan0;
byte* pDst = (byte*) dstdata.scan0;
int offset = dstdata.stride-w * 4;
int Gray, GRAYSRC, Graygauss;
for (int j = 0; J < H; j + +)
{
for (int i = 0; i < W; i++)
{
GRAYSRC = (Pdst[0] + pdst[1] + pdst[2])/3;
Graygauss = 255-(Pgauss[0] + pgauss[1] + pgauss[2])/3;
Gray = graysrc + (GRAYSRC * graygauss)/(256-graygauss);
Gray = math.min (255, Math.max (0, Gray));
Pdst[0] = (byte) gray;
PDST[1] = (byte) gray;
PDST[2] = (byte) gray;
PDST[3] = (byte) 255;
Pgauss + = 4;
PDst + = 4;
}
Pgauss + = offset;
PDst + = offset;
}
Dst. Unlockbits (Dstdata);
Gaussbitmap.unlockbits (Edgedata);
return DST;
}

As shown below:

Original

Sketch Filter

Finally put the full C#/C program demo download Connection: http://www.zealpixel.com/thread-64-1-1.html

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Image Filter Art---(Sketch filter) sketch Filter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.