【发布时间】:2020-07-16 14:06:08
【问题描述】:
我想要做的是调整常规 pgm 图像的大小,将 3--100X100 的因子变为 33X33,我使用指针数组来存储原始图像和调整大小的图像,原始图像将是 10000 长并且调整大小的图像将是 1089 长,我正在尝试获取宽度维度中的每 3 个元素并跳过两个宽度行(因为高度也需要减少),当我写它时,我不断得到一个奇怪的模糊图像一个 pgm 输出,我知道可能会有一点差异,因为我们正在舍入高度和宽度,这只是代码的一部分。
enter code here
int k,l,m;
image =(unsigned char*) malloc((width*height) * sizeof(unsigned char));
int thumbHeight=round(height/3);
int thumbWidth =round(width/3);
resizedImage =(unsigned char*) malloc(((resizedWidth*resizedHeight)) * sizeof(unsigned char));
for(l=0;l<resizedHeight;l++){
for(k=0;k<resizedWidth;k++){
*resizedImage= *image;
image++;
image++;
}
//skipping two lines
for (m=0;m<width*2;m++){
image++;
}
}
【问题讨论】: