当前位置:网站首页>[opencv practice] in cold winter, there will be a rainbow. Do you love this special effect?

[opencv practice] in cold winter, there will be a rainbow. Do you love this special effect?

2022-06-11 00:02:00 Programmer pear

Preface

author :“ Programmer pear ”

** The article brief introduction **: This article mainly explains the use of Opencv The library adds rainbow effects to pictures and videos .

** Article source code access **: In order to thank everyone who pays attention to me, the project source code of each article is distributed free of charge

Enjoy drops

Click here for the blue line font , If you need any source code, remember to say the title and name ! I can also !

Welcome friends give the thumbs-up 、 Collection 、 Leaving a message.

Text

There is always light rain in winter in the South , Sunny days are becoming extravagant .( Shivering with cold .jpg)

here , How I wish I could feel the warmth of summer , Even if it's rainy , Sometimes I see rainbows ! Think of this and start , look for

Find summer photos and videos , use OpenCV Add a rainbow to them .

 

Implementation steps ——

1) Prepare a picture of summer scenery , Load read .


Mat src = imread("summer.jpg");

 2) Create a black image of the same size as the original image , Then draw the rainbow by drawing an elliptic function .


Mat dst;
int row = srcImg.rows;
int col = srcImg.cols;
Mat img(row, col, CV_8UC3, Scalar::all(0));
  
ellipse(img, Point(col/2, row*4/5), Size(col/2+100, row*4/5), 180, 0, 180, Scalar(255,0,128), 5);
ellipse(img, Point(col/2,row*4/5), Size(col/2-8+100,row*4/5-8), 180, 0, 180, Scalar(255,0,0), 5);
ellipse(img, Point(col/2,row*4/5), Size(col/2-8*2+100,row*4/5-8*2), 180, 0, 180, Scalar(255,255,0), 5);
ellipse(img, Point(col/2,row*4/5), Size(col/2-8*3+100,row*4/5-8*3), 180, 0, 180, Scalar(0,255,0), 5);
ellipse(img, Point(col/2,row*4/5), Size(col/2-8*4+100,row*4/5-8*4), 180, 0, 180, Scalar(0,255,255), 5);
ellipse(img, Point(col/2,row*4/5), Size(col/2-8*5+100,row*4/5-8*5), 180, 0, 180, Scalar(0,128,255), 5);
ellipse(img, Point(col/2,row*4/5), Size(col/2-8*6+100,row*4/5-8*6), 180, 0, 180, Scalar(0,0,255), 5);

 3) Gaussian blur , Make the rainbow edge softer transition .

GaussianBlur(img, img, Size(7, 7), 0, 0);

4) Rainbow image and landscape image are mixed and superimposed ( Poisson fusion is better ).

addWeighted(srcImg, 1.0, img, 0.2, 0, dst);

Change some pictures to test : 

 

 

 

  summary

Hee hee , These rainbows look good ~ The video test is up to you Why do I take the source code

Follow Xiaobian for more wonderful content ! Remember to click on the portal

Remember Sanlian ! If you need packaged source code + Free sharing of materials ! Portal

 

原网站

版权声明
本文为[Programmer pear]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206102242248676.html

随机推荐