opencv--Old photo effect

Source: Internet
Author: User

Define head function#ifndef ps_algorithm_h_included#define ps_algorithm_h_included#include <iostream># Include <string> #include "cv.h" #include "highgui.h" #include "cxmat.hpp" #include "cxcore.hpp" using namespace std Using namespace Cv;void show_image (mat&, const string &); #endif//Ps_algorithm_h_included/*this program would ge Nerate "Old picture" effect.*/#include "ps_algorithm.h" #include <time.h>using namespace std;using namespace CV;    int main (void) {string Img_name ("9.jpg");    Mat image_in;    Image_in=imread (Img_name);    Show_image (image_in, img_name);    Mat image_out (Image_in.size (), CV_32FC3);    Image_in.convertto (Image_out, CV_32FC3);    Mat image_2 (Image_in.size (), CV_32FC3);    Image_in.convertto (image_2, CV_32FC3);    Mat R (image_in.rows, Image_in.cols, CV_32FC1);    Mat g (Image_in.rows, Image_in.cols, CV_32FC1);    Mat B (Image_in.rows, Image_in.cols, CV_32FC1);    Mat Out[]={b, G, r};    Split (image_2, out); Mat r_new (Image_in.rows, Image_In.cols, CV_32FC1);    Mat g_new (Image_in.rows, Image_in.cols, CV_32FC1);    Mat b_new (Image_in.rows, Image_in.cols, CV_32FC1);    R_new=0.393*r+0.769*g+0.189*b;    G_new=0.349*r+0.686*g+0.168*b;    B_new=0.272*r+0.534*g+0.131*b;    Mat rgb[]={b_new, G_new, r_new};    Merge (Rgb,3,image_out);    image_out=image_out/255;    Show_image (Image_out, "out.jpg");    Imwrite ("Out.jpg", image_out*255);    Waitkey (); cout<< "All are well." <<endl;} #include "ps_algorithm.h" #include <iostream> #include <string>using namespace std;using namespace cv;void    Show_image (mat& Image, const string& str) {Namedwindow (Str.c_str (), cv_window_autosize); Imshow (Str.c_str (), Image);}

Original




opencv--Old photo effect

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.