当前位置:网站首页>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);
}
}
边栏推荐
- [blackmail virus data recovery] suffix Rook3 blackmail virus
- Qunhui NAS configuring iSCSI storage
- Googlenet network explanation and model building
- PCL calculates the intersection of three mutually nonparallel planes
- sqli-labs第1关
- Benefits of ufcs of D
- HCIA - application layer
- STM32 new project (refer to punctual atom)
- Pointer initialization
- OpenShift 容器平台社区版 OKD 4.10.0部署
猜你喜欢

Analysis of the use of comparable, comparator and clonable interfaces

Sentinel easy to use

File upload and download performance test based on the locust framework

小米电视不能访问电脑共享文件的解决方案

Minecraft module service opening

ARP及ARP欺骗

Minecraft空岛服开服

Detailed explanation of NIN network

Tcp/ip - transport layer
![[blackmail virus data recovery] suffix Hydra blackmail virus](/img/27/f44334cf98229d0f8b33c70a878ca8.jpg)
[blackmail virus data recovery] suffix Hydra blackmail virus
随机推荐
commands out of sync. did you run multiple statements at once
C call system sound beep~
Makefile基本原理
NPOI 导出Word 字号对应
Pointer initialization
History of Web Technology
Benefits of ufcs of D
Use the numbers 5, 5, 5, 1 to perform four operations. Each number should be used only once, and the operation result value is required to be 24
C# 调用系统声音 嘀~
C Gaode map obtains the address according to longitude and latitude
Sentinel easy to use
Qt的connect函数和disconnect函数
判断是否是数独
Network security - summary and thinking of easy-to-use fuzzy tester
统计字符串中各类字符的个数
Sentinel 简单使用
C nail development: obtain all employee address books and send work notices
kubeadm部署kubernetes v1.23.5集群
First week of JS study
Zipkin is easy to use