Atitit atitit image processing Oilpaint oil painting filter Watercolor Source Realization

Source: Internet
Author: User

Atitit A Titit the image processing oilpaint oil Painting Filter Watercolor source realization

1.1. specific principles reference 1

2. the Watercolor filter algorithm is as follows:1

2.1. This is actually the process of reducing the dimension at the grayscale level. 2

2.2. radius of the template radius is used to adjust the watercolor level of watercolor. that is, the process of reducing the dimensions of the color 2

1.1. Specific principle Reference

A Titit effect of image processing on imitation oil painting oilpaint oil painting filter Watercolor cartoon filter v2

2. The Watercolor filter algorithm is as follows:

Grayscale, discretization (clustering).

Grayscale Level N is the color of the most used in watercolor painting level, general 7 species for good

1, assuming that the original image is F (x, Y), Gray to get g (x, y);

2, build a radius of the square template m, the edge length is 2*radius+1;

3, the M traverses each pixel in turn on F, for the current pixel p (x, y):

settings Gray level n, because the image has a gray value range of 0-255,  

3.1 first divides the range of 0-255 by N to n Gray level for the corresponding pixel in the template, we put it into the corresponding Gray level

3.2 Statistics of n Grayscale Level number of pixels, the one that counts the most pixels level inside, the pixel's Individual Color Components The mean value Mean, which is the value of the template center pixel p (x, y).

2.1. This is actually the process of reducing the dimension of the gray level.

Note: Number of paint barrels n can adjust image smoothness , gray level ,

2.2. The radius radius of the template is used to adjust the watercolor level. which is the process of reducing the dimensions of the color

3. Source code algorithm /atiplatf_cms/src/com/attilax/img/oilpaintv2.java

private void Process (bufferedimage src, int graylevdeep, int radis) throws Fileexistex {

initializing a matrix scan template

Mtrx = new Matrix (). Setradis (Radis). setimg (SRC);

Initialize a grayscale hierarchy classifier

Graylayercater GrayLayerCater1 = new Graylayercater (); Ini

graylayercater_rgbmod_dbg = GrayLayerCater1;

initializes the grayscale level to N - tier

List<layer> li = Graylayercater1.inilayers_groupbygray (graylevdeep, 255);

Initialize the marquee matrix scanner

Imgtraver_bymatrix trvr = new Imgtraver_bymatrix (MTRX);

set up event handling for scanning to each pixel

Trvr.cur_pix_point_evt_handler = (cur_point), {

The classification of the pixels in the template marquee within the gray level, placed in different levels of gray

Graylayercater1.assignmatrixcolorstobukesbypercolorgray (MTRX);

The gray level that gets the most pixels, discarding other levels of pixel information

Layer MaxPixsLayer1 = Graylayercater1.maxpixslayer ();

calculate the color mean, calculate each RGB component separately, and synthesize

Color Avgcolor = MAXPIXSLAYER1.AVGCOLOR_RETCLR ();

Point mtrxcenter_point = Mtrx.getcenterpoint ();

try {

Src.setrgb (Cur_point.x, Cur_point.y, Avgcolor.getrgb ());

// because the template may go beyond the bounds of the image when scanning, the last line of pixels simplifies processing, ignoring errors

} catch (ArrayIndexOutOfBoundsException e) {

System.out.println (E.getmessage () + "point:" + cur_point);

}

};

Trvr.trave (SRC); Start Scanning

}

author::  Nickname :Old Wow's claws( Full Name::AttilaxAkbar Al Rapanui Attilaksachanui) 

Kanji Name: Etila ( Ayron) , email:[email protected]

reprint Please indicate source: http://www.cnblogs.com/attilax/

Atiend

Atitit atitit image processing Oilpaint oil painting filter Watercolor Source Realization

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.