当前位置:网站首页>Essay: RGB image color separation (with code)
Essay: RGB image color separation (with code)
2022-07-02 08:49:00 【Code pirate captain】
I originally wanted to write several grayscale functions , The gray image is boring , So I wrote this ;
take BGR Separation of three primary colors : The code is as follows
Method 1:
uchar* pImgB = new uchar[col*row*3];
uchar* pImgG = new uchar[col * row * 3];
uchar* pImgR = new uchar[col * row * 3];
for (int i = 0; i < row * col * 3; i+=3)
{
pImgB[i] = pImg[i]; // Separate blue
pImgB[i + 1] = 0;
pImgB[i + 2] =0;
pImgG[i] = 0; // Separate out green
pImgG[i + 1] = pImg[i + 1];
pImgG[i + 2] = 0;
pImgR[i] = 0; // Separate out red
pImgR[i + 1] = 0;
pImgR[i + 2] = pImg[i + 2];
}
delete[] pImgB;
delete[] pImgG;
delete[] pImgR;
Use opencv The pointer to ( Comparison method 1 slow 30 times )
Method 2:
for (int i = 0; i < img.rows; i ++)
{
for (int j = 0; j < img.cols; j++)
{
*imgB.ptr(i, j) = *img.ptr(i, j); // Separate blue
*(imgB.ptr(i, j) + 1) = 0;
*(imgB.ptr(i, j) + 2) = 0;
*imgG.ptr(i, j) = 0; // Separate blue
*(imgG.ptr(i, j) + 1) = *(img.ptr(i, j) + 1);
*(imgG.ptr(i, j) + 2) = 0;
*imgR.ptr(i, j) = 0; // Separate blue
*(imgR.ptr(i, j) + 1) = 0;
*(imgR.ptr(i, j) + 2) = *(img.ptr(i, j) + 2);
}
}
边栏推荐
- Minecraft air Island service
- Solution of Xiaomi TV's inability to access computer shared files
- C Gaode map obtains the address according to longitude and latitude
- idea中注释代码取消代码的快捷键
- c语言将字符串中的空格替换成%20
- Concise analysis of redis source code 11 - Main IO threads and redis 6.0 multi IO threads
- Web security -- core defense mechanism
- 什么是SQL注入
- Honeypot attack and defense drill landing application scheme
- sqli-labs第1关
猜你喜欢

C language custom type enumeration, Union (clever use of enumeration, calculation of union size)

Finishing the interview essentials of secsha system!!!

Minecraft模组服开服

IP协议与IP地址

Linked list classic interview questions (reverse the linked list, middle node, penultimate node, merge and split the linked list, and delete duplicate nodes)

Minecraft插件服开服

Programmer training, crazy job hunting, overtime ridiculed by colleagues deserve it

Minecraft group service opening

commands out of sync. did you run multiple statements at once

HackTheBox-Gunship
随机推荐
Installing Oracle database 19C RAC on Linux
c语言自定义类型枚举,联合(枚举的巧妙使用,联合体大小的计算)
Sqli labs level 1
Kubedm deploys kubernetes v1.23.5 cluster
C language custom types - structure, bit segment (anonymous structure, self reference of structure, memory alignment of structure)
[flask] ORM one-to-one relationship
Judge whether it is Sudoku
C Gaode map obtains the address according to longitude and latitude
Linux二进制安装Oracle Database 19c
Minecraft air Island service
什么是SQL注入
TCP/IP—传输层
C language replaces spaces in strings with%20
gocv拆分颜色通道
随笔:RGB图像颜色分离(附代码)
Function ‘ngram‘ is not defined
sqli-labs第1关
Openshift deployment application
kubernetes部署loki日志系统
Finishing the interview essentials of secsha system!!!