Learning opencv: Filter series (10) -- old colors, comic strips, casting, and freezing

Source: Internet
Author: User

========================================================== ======

Copyright: bear does not go to the lab csdn blog

========================================================== ======


Principles of old colors



# Include <opencv/cv. h> # include <opencv/highgui. h> using namespace CV; using namespace STD; int main () {mat src = imread ("D:/scene04.jpg", 1); int width = SRC. cols; int heigh = SRC. rows; RNG; mat img (SRC. size (), cv_8uc3); For (INT y = 0; y 

Source image:



Old colors:





Links:

The effect of the comic picture is similar to that of the image after the grayscale image. They are all grayscale images, but the comic picture increases the contrast of the image and improves the overall brightness and brightness. algorithm:

R = |g – b + g + r| * r / 256

G = |b – g + b + r| * r / 256;

B = |b – g + b + r| * g / 256;

# Include <math. h> # include <opencv/cv. h> # include <opencv/highgui. h> using namespace CV; using namespace STD; int main () {mat src = imread ("D:/scene04.jpg", 1); int width = SRC. cols; int heigh = SRC. rows; RNG; mat img (SRC. size (), cv_8uc3); For (INT y = 0; y 

Comic effect:

Casting Algorithm

R = r * 128/(g + B + 1 );

G = g * 128/(R + B + 1 );

B = B * 128/(g + R + 1 );

Freezing Algorithm

R = (r-g-B) * 3/2;
G = (G-r-B) * 3/2;
B = (B-G-r) * 3/2;


# Include <math. h> # include <opencv/cv. h> # include <opencv/highgui. h> # define maxsize (32768) using namespace CV; using namespace STD; void casting (const mat & SRC) {mat IMG; SRC. copyto (IMG); int width = SRC. cols; int heigh = SRC. rows; mat dst (IMG. size (), cv_8uc3); For (INT y = 0; y 

Casting:

Frozen:



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.