日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪(fǎng)問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

为图片添加LOMO效果

發(fā)布時(shí)間:2023/12/16 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 为图片添加LOMO效果 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

From 《OpenCV By Example》

1. A color manipulation with a look up table that applies a curve to the red channel

2. A vintage effect that applies a dark halo to the image.


#include <iostream>using namespace std;#include "opencv2/core.hpp" #include "opencv2/highgui.hpp" #include "opencv2/imgproc.hpp"using namespace cv;int main() {Mat img = imread("1.jpg");float radius = img.cols > img.rows ? (img.rows / 3) : (img.cols / 3);Mat result;const double exponential_e = exp(1.0);// Create Lookup table for color curve effectMat lut(1, 256, CV_8UC1);for (int i = 0; i < 256; i++){float x = (float)i / 256.0;lut.at<uchar>(i) = cvRound(256 * (1 / (1 + pow(exponential_e, -((x - 0.5) / 0.1)))));}// Split the image channels and apply curve transform only to red channelvector<Mat> bgr;split(img, bgr);LUT(bgr[2], lut, bgr[2]);//merge resultmerge(bgr, result);// Create image for halo darkMat halo(img.rows, img.cols, CV_32FC3, Scalar(0.3, 0.3, 0.3));// Create circlecircle(halo, Point(img.cols / 2, img.rows / 2), img.cols / 3, Scalar(1, 1, 1), -1);blur(halo, halo, Size(img.cols / 3, img.cols / 3));// Convert the result to float to allow multiply by 1 factorMat resultf;result.convertTo(resultf, CV_32FC3);// Multiply our result with halomultiply(resultf, halo, resultf);// convert to 8 bitsresultf.convertTo(result, CV_8UC3);// show resultimshow("Lomograpy", result);waitKey(0);return 0; }

原圖為:


效果圖如下:


總結(jié)

以上是生活随笔為你收集整理的为图片添加LOMO效果的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。