【发布时间】:2013-05-28 07:37:06
【问题描述】:
我完全是初学者。我会尽可能多地解释自己。
int i, j;
string filename;
cout << "Please enter the file name: " << endl;
cin >> filename;
fstream stream;
stream.open(filename.c_str(),
ios::in|ios::out|ios::binary);
int file_size = get_int(stream, 2);
int start = get_int(stream, 10);
int width = get_int(stream, 18);
int height = get_int(stream, 22);
这部分应该获取文件及其值。
for ( i = 0; i < height; i++ )
{
for ( j = 0; j < width; j++)
{
for (int k = 0; k < split*split; k++){
int pos = stream.tellg();
int blue = stream.get();
int green = stream.get();
int red = stream.get();
这会到达每个像素内部并获取 RBG 值。
我想要的是首先将 RBG 值存储到一个二维数组中,然后对该数组进行一些操作。然后我想创建一个带有操作图像的新文件。
我不知道,所以一些说明和一些代码会很有帮助。
【问题讨论】:
-
代码here
-
我推荐使用 OpenCV,使用它读取图像需要两行代码。
-
Ty mate,但如果可能的话,我想在没有任何库的情况下这样做。