当前位置: 首页 > news >正文

天津市做网站杭州seo靠谱

天津市做网站,杭州seo靠谱,wordpress 图片的设置,zencart网站建设OpenCV颜色空间实战 〇、Coding实战内容一、imread1.1 函数介绍1.2 Flags1.3 Code 二. 色彩空间2.1 获取单色空间2.2. HSV、YUV、RGB2.3. 不同颜色空间应用场景 〇、Coding实战内容 OpenCV imread()方法不同的flags差异性获取单色通道【R通道、G通道、B通道】HSV、YUV、RGB 一…

OpenCV颜色空间实战

  • 〇、Coding实战内容
  • 一、imread
    • 1.1 函数介绍
    • 1.2 Flags
    • 1.3 Code
  • 二. 色彩空间
    • 2.1 获取单色空间
    • 2.2. HSV、YUV、RGB
    • 2.3. 不同颜色空间应用场景

〇、Coding实战内容

  1. OpenCV imread()方法不同的flags差异性
  2. 获取单色通道【R通道、G通道、B通道】
  3. HSV、YUV、RGB

一、imread

1.1 函数介绍

/**
The function imread loads an image from the specified file and returns it
@param filename Name of file to be loaded.
@param flags Flag that can take values of cv::ImreadModes
**/
CV_EXPORTS_W Mat imread( const String& filename, int flags = IMREAD_COLOR );

1.2 Flags

// enum ImreadModes {
//        IMREAD_UNCHANGED            = -1, //!< If set, return the loaded image as is (with alpha channel, otherwise it gets cropped). Ignore EXIF orientation.
//        IMREAD_GRAYSCALE            = 0,  //!< If set, always convert image to the single channel grayscale image (codec internal conversion).
//        IMREAD_COLOR                = 1,  //!< If set, always convert image to the 3 channel BGR color image.
//        IMREAD_ANYDEPTH             = 2,  //!< If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit.
//        IMREAD_ANYCOLOR             = 4,  //!< If set, the image is read in any possible color format.
//        IMREAD_LOAD_GDAL            = 8,  //!< If set, use the gdal driver for loading the image.
//        IMREAD_REDUCED_GRAYSCALE_2  = 16, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/2.
//        IMREAD_REDUCED_COLOR_2      = 17, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/2.
//        IMREAD_REDUCED_GRAYSCALE_4  = 32, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/4.
//        IMREAD_REDUCED_COLOR_4      = 33, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/4.
//        IMREAD_REDUCED_GRAYSCALE_8  = 64, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/8.
//        IMREAD_REDUCED_COLOR_8      = 65, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/8.
//        IMREAD_IGNORE_ORIENTATION   = 128 //!< If set, do not rotate the image according to EXIF's orientation flag.
//      };

常用的有三种
a. -1 IMREAD_UNCHANGED:忽视alpha通道
b. 0 IMREAD_GRAYSCALE:灰度图
c. 1 IMREAD_COLOR 不填默认值,且格式为BGR

1.3 Code

assign_2.cpp

#include <opencv2/opencv.hpp>
#include <iostream>
#include <vector>
#include <string>using namespace cv;
using namespace std;#include <opencv2/opencv.hpp>
#include <iostream>
#include <vector>
#include <string>
using namespace cv;
using namespace std;int main(int argc, char *argv[])
{std::string filePath = std::string(__FILE__);size_t pos = filePath.find_last_of("/\\");std::string rootPath = filePath.substr(0, pos); // string path = string(__BASE_FILE__)+"/img.webp";cout << rootPath;//IMREAD_COLOR BGRMat image = imread(rootPath+"/img.webp",IMREAD_COLOR);//IMREAD_UNCHANGED, 无alpha通道Mat image1 = imread(rootPath+"/img.webp",IMREAD_UNCHANGED);//IMREAD_GRAYSCALE 灰度图Mat image2 = imread(rootPath+"/img.webp",IMREAD_GRAYSCALE);namedWindow("imread imread_unchanged");    // 创建一个标题为 "hello" 的窗口imshow("hello", image); // image1, image2 //在窗口 "hello" 中显示图片waitKey(0);              // 等待用户按下键盘destroyWindow("hello");  // 销毁窗口 "hello"return 0;
}

输出结果:
在这里插入图片描述在这里插入图片描述在这里插入图片描述

二. 色彩空间

2.1 获取单色空间

#include <opencv2/opencv.hpp>
#include <iostream>
#include <vector>
#include <string>
using namespace cv;
using namespace std;int main(int argc, char *argv[])
{/*** 二、色彩空间* *///红色vector<Mat> channels;split(image, channels);//bgrchannels[0] = Mat::zeros(image.rows, image.cols, CV_8UC1); // bluechannels[1] = Mat::zeros(image.rows, image.cols, CV_8UC1); // greenMat red;merge(channels, red);//蓝色vector<Mat> channels_1;split(image, channels_1);//bgrchannels[1] = Mat::zeros(image.rows, image.cols, CV_8UC1); // greenchannels[2] = Mat::zeros(image.rows, image.cols, CV_8UC1); // redMat blue;merge(channels, blue);//绿色vector<Mat> channels_2;split(image, channels_2);//bgrchannels[0] = Mat::zeros(image.rows, image.cols, CV_8UC1); // greenchannels[2] = Mat::zeros(image.rows, image.cols, CV_8UC1); // redMat green;merge(channels, green);
}

输出结果
在这里插入图片描述在这里插入图片描述在这里插入图片描述

2.2. HSV、YUV、RGB

int main(int argc, char *argv[])
{std::string filePath = std::string(__FILE__);size_t pos = filePath.find_last_of("/\\");std::string rootPath = filePath.substr(0, pos); // string path = string(__BASE_FILE__)+"/img.webp";cout << rootPath;Mat image = imread(rootPath+"/img.webp",IMREAD_COLOR);/*** 三、色彩空间**/Mat hsv;cvtColor(image,hsv,COLOR_BGR2HSV);Mat rgb;cvtColor(image,hsv,COLOR_BGR2RGB);Mat yuv;cvtColor(image,yuv,COLOR_BGR2YUV);namedWindow("hsv");    imshow("hsv", hsv); waitKey(0);            destroyWindow("hsv"); return 0;
}

输出结果
在这里插入图片描述在这里插入图片描述在这里插入图片描述

颜色空间:
具体可搜索wikipedia,有很详细的介绍
1. HSV vs HSB:https://en.wikipedia.org/wiki/HSL_and_HSV
2. YUV:可参考本人以前的一篇文章,https://blog.csdn.net/Scott_S/article/details/118525159?spm=1001.2014.3001.5501

2.3. 不同颜色空间应用场景

  1. RGB:视频监视器,彩色摄像机
  2. HSV [色调、饱和度、亮度]:彩色处理为目的
  3. CMYK :印刷行业,如果用过小米照片打印机,就会发现一张照片需要渲染4次,按照如下流程
    • Cyan:蓝青色;
    • magenta:品红、杨红;
    • Yellow:黄色;
    • Key: (black)
  4. YUV :电视信号传输,占用极少的带宽
http://www.ds6.com.cn/news/40528.html

相关文章:

  • 南昌网站建设公司网站建设公司上海企业优化
  • 磐安网站建设口碑最好的it培训机构
  • 上海鹭城建设集团网站品牌宣传策略有哪些
  • 网站建设教程赚找湖南岚鸿认 可网络营销手段有哪些
  • 网站开发 前端 后端济南网络推广网络营销
  • 青岛网站建设青岛新思维seo原创工具
  • 网站空间到期提示软文写作经验
  • 网站建设制作方案seo网站排名助手
  • wordpress转代码青岛关键词优化seo
  • 深圳市做网站推广什么软件可以长期赚钱
  • dede 做手机网站营销网站建设软件下载
  • 西安手机网站零食软文范例300字
  • 企业网站的制作周期爱链网中可以进行链接买卖
  • 校园网站建设的意见与建议新闻发稿发布平台
  • 免费打开的网站网络营销方案有哪些
  • 网站正在建设中 源码天津百度分公司
  • 做帖子网站百度搜索网页
  • 做云图的网站网页设计用什么软件做
  • 重庆企业网站的推广正规专业短期培训学校
  • 实用的网站郑州seo优化顾问阿亮
  • 网络服务商网站网络营销成功案例分析其成功原因
  • 微信群投票网站怎么做青海百度关键词seo
  • 自己弄个网站网站外链怎么发布
  • 网站开发方案关键词怎么写
  • 试用网站 源码seo优化包括
  • wordpress重定向次数过多seo搜索引擎优化工资薪酬
  • 怎么做外网的网站电商运营培训哪个机构好
  • 做响应式网站制作天津短视频seo
  • 给网站做友情链接免费外链发布平台在线
  • 做网站用多大的服务器关键词优化排名用什么软件比较好