【发布时间】:2016-10-11 23:15:55
【问题描述】:
我有一个卷文件,其切片长度可变,图像高度为 640,图像宽度为 512。我想将其转换为高度为 620,宽度为 420 的文件,并将其写入新的文件。我想从高度的顶部取出 20 个像素,并从宽度的每一侧取出 46 个像素来调整大小。每个像素都是无符号的 16 位。我不确定如何进行实际操作。
这是我的主要内容:
FILE* pfile = NULL;
FILE* pfile2 = NULL;
pFile = fopen("test.vol", "rb");
fseek (pFile , 0 , SEEK_END);
int fileData = ftell(pFile);
rewind(pFile);
char* FileBuffer = new char[fileData];
fread(FileBuffer, fileData, 1, pFile);
int height = 640;
int width = 512;
int slizeSize = height * width * 2;
int sliceCount = fileData / sliceSize;
uint16_t pixels;
int newHeight = height - 20;
int newWidth = width - 92;
int newSliceSize = newHeight * newWidth * 2;
int newImageSize = newSliceSize * sliceCount;
char* NewFileBuffer = new char[newImageSize];
for (int i = 0; i < newHeight; i++) {
for (int i = 0; i < newWidth; i++) {
}
// need help in these for loops and after
}
fclose (pFile);
free (FileBuffer);
pFile2 = fopen("test2.vol", "wb");
fwrite(NewFileBuffer, NewImageSize, 1, pFile2);
【问题讨论】:
标签: c++ image-processing