Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/132.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何创建具有电视效果的图像?_C++_Opencv - Fatal编程技术网

C++ 如何创建具有电视效果的图像?

C++ 如何创建具有电视效果的图像?,c++,opencv,C++,Opencv,我需要处理带有电视效果的图像。这里是处理过的图像样本的链接 有人能告诉我openCV库是否能做到这一点吗?或者我可以使用其他库来实现此目的?当然可以。可以操纵像素。所以你只需要自己编写这样一个过滤器。 这是我想到的。也许你可以根据自己的喜好调整一下 它拍摄一张图像,稍微降低颜色的饱和度,然后根据垂直正弦函数增加蓝色部分 #include <opencv2/opencv.hpp> #include <highgui.h> #include <cmath> d

我需要处理带有电视效果的图像。这里是处理过的图像样本的链接


有人能告诉我openCV库是否能做到这一点吗?或者我可以使用其他库来实现此目的?

当然可以。可以操纵像素。所以你只需要自己编写这样一个过滤器。 这是我想到的。也许你可以根据自己的喜好调整一下

它拍摄一张图像,稍微降低颜色的饱和度,然后根据垂直正弦函数增加蓝色部分

#include <opencv2/opencv.hpp>
#include <highgui.h> 
#include <cmath>

double wavelength = 40;
double intensity = 0.5;

double decolorisation = 0.7;

int main(int argc, char** argv)
{
    cv::Mat img = imread(argv[1]);
    cv::Mat outImg = img.clone();

    for(int i=0; i<img.rows; i++)
        for(int j=0; j<img.cols; j++)
        {
            // desaturate the image
            double meanColor = (img.at<cv::Vec3b>(i,j)[0] + img.at<cv::Vec3b>(i,j)[1] + img.at<cv::Vec3b>(i,j)[3]) / 3.0;
            cv::Vec3b newColor;
            newColor[0] = (1-decolorisation)*img.at<cv::Vec3b>(i,j)[0] + decolorisation*meanColor; 
            newColor[1] = (1-decolorisation)*img.at<cv::Vec3b>(i,j)[1] + decolorisation*meanColor; 
            newColor[2] = (1-decolorisation)*img.at<cv::Vec3b>(i,j)[2] + decolorisation*meanColor; 

            // boost the blue channel
            double coeff = 0.5 + sin((2*M_PI*i)/wavelength)/2.0;
            newColor[0] = newColor[0] + intensity * coeff * (255-newColor[0]);

            outImg.at<cv::Vec3b>(i,j) = newColor;
        }

    cv::imshow("Original",img);
    cv::imshow("Televised",outImg);
    waitKey(0);          
}
#包括
#包括
#包括
双波长=40;
双强度=0.5;
双脱色=0.7;
int main(int argc,字符**argv)
{
cv::Mat img=imread(argv[1]);
cv::Mat outImg=img.clone();

对于(inti=0;i当然可以。你可以操纵像素。所以你只需要自己编写这样一个过滤器。 这是我想出来的。也许你可以根据自己的喜好调整一下

它拍摄一张图像,稍微降低颜色的饱和度,然后根据垂直正弦函数增加蓝色部分

#include <opencv2/opencv.hpp>
#include <highgui.h> 
#include <cmath>

double wavelength = 40;
double intensity = 0.5;

double decolorisation = 0.7;

int main(int argc, char** argv)
{
    cv::Mat img = imread(argv[1]);
    cv::Mat outImg = img.clone();

    for(int i=0; i<img.rows; i++)
        for(int j=0; j<img.cols; j++)
        {
            // desaturate the image
            double meanColor = (img.at<cv::Vec3b>(i,j)[0] + img.at<cv::Vec3b>(i,j)[1] + img.at<cv::Vec3b>(i,j)[3]) / 3.0;
            cv::Vec3b newColor;
            newColor[0] = (1-decolorisation)*img.at<cv::Vec3b>(i,j)[0] + decolorisation*meanColor; 
            newColor[1] = (1-decolorisation)*img.at<cv::Vec3b>(i,j)[1] + decolorisation*meanColor; 
            newColor[2] = (1-decolorisation)*img.at<cv::Vec3b>(i,j)[2] + decolorisation*meanColor; 

            // boost the blue channel
            double coeff = 0.5 + sin((2*M_PI*i)/wavelength)/2.0;
            newColor[0] = newColor[0] + intensity * coeff * (255-newColor[0]);

            outImg.at<cv::Vec3b>(i,j) = newColor;
        }

    cv::imshow("Original",img);
    cv::imshow("Televised",outImg);
    waitKey(0);          
}
#包括
#包括
#包括
双波长=40;
双强度=0.5;
双脱色=0.7;
int main(int argc,字符**argv)
{
cv::Mat img=imread(argv[1]);
cv::Mat outImg=img.clone();

对于(int i=0;iOpenCV是一个低级处理库,因此如果您花一些时间来模拟效果,答案是肯定的。OpenCV是一个低级处理库,因此如果您花一些时间来模拟效果,答案是肯定的。谢谢。我将尝试实现它,并会让您知道。谢谢。我将尝试实现它,并将你知道的。