如何通过 c++ 获取图像的所有像素数据 (RGB)
How to get all the pixel data (RGB) of an image through c++
从JPG或PNG文件中,我想要2D数组形式的像素数据。
执行该任务的过程是什么,或者哪些库可以完成该任务?
尝试 openCV 库。这是您可以下载并安装它的网站。下面是执行所需操作的代码:
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
Mat image = imread("C:/.../image1.jpg");
Vec3b buf;
for(int i = 0; i < image.rows; i++)
for(int j = 0; j < image.cols; j++)
{
buf = image.at<Vec3b>(i,j);
array_B[i][j] = buf[0];
array_G[i][j] = buf[1];
array_R[i][j] = buf[2];
}
//imwrite("C:/.../image2.jpg",image3);
imshow("Image",image);
waitKey(0);
}
相关文章:
- OpenGL - 每个三角形的像素数不正确
- C++ 在给定像素数据数组的表单上绘制矩形
- 从位图提取像素数据的问题
- 如何在 sfml 中使用图像中的像素数组
- 如何将 QImage 中的像素数据转换为其他格式
- 如何将CImg函数与像素数据一起使用?
- 将原始像素数据转换为qpixmap
- qimage:如何正确破坏指向像素数据的指针
- 如何通过 c++ 获取图像的所有像素数据 (RGB)
- 如何从窗口中获取像素数据像素缓冲区并提取RGB
- 设备定位的像素数组(从 C++ AMP)到 使用 D3D / D2D 的窗口
- SetPixel在像素数量后崩溃
- I'm试图将像素数据转换为OpenCV Mat对象
- 使用opencv将像素数据分配到向量中
- 如何在 c++ 中最有效地将像素数组呈现到窗口
- 将浮点像素数据从文件中读回 C#
- 在窗口中的屏幕上获取坐标像素数据的简单方法
- 有没有办法在不复制所有像素的情况下将现有的像素数组转换为位图
- 在 C 或 C++ 中将 JPEG 或 PNG 图像作为像素数据打开
- 如何写入原始像素数据并另存为位图