当前位置:网站首页>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 install resource pack

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

k8s入门:Helm 构建 MySQL
![[blackmail virus data recovery] suffix Crylock blackmail virus](/img/b2/8e3a65dd250b9194cfc175138c740c.jpg)
[blackmail virus data recovery] suffix Crylock blackmail virus

OpenFeign 簡單使用

队列的基本概念介绍以及典型应用示例
![[untitled]](/img/6c/df2ebb3e39d1e47b8dd74cfdddbb06.gif)
[untitled]

ARP及ARP欺骗

Illegal use of crawlers, an Internet company was terminated, the police came to the door, and 23 people were taken away

小米电视不能访问电脑共享文件的解决方案
随机推荐
History of Web Technology
Kubernetes deploys Loki logging system
C Gaode map obtains the address according to longitude and latitude
Tensorflow2 keras 分类模型
Installing Oracle database 19C RAC on Linux
[blackmail virus data recovery] suffix Crylock blackmail virus
Minecraft module service opening
Qt的拖动事件
NPOI 导出Word 字号对应
libusb的使用
Qt——如何在QWidget中设置阴影效果
C nail development: obtain all employee address books and send work notices
C language custom type enumeration, Union (clever use of enumeration, calculation of union size)
commands out of sync. did you run multiple statements at once
OpenFeign 简单使用
什么是SQL注入
Oracle related statistics
小米电视不能访问电脑共享文件的解决方案
Pointer initialization
Sqli labs level 1