#include <stdio.h>
#include <stdlib.h>
#include "imageio.h"
#include "imageio.c"
int main()
{
int i,j;
IMAGE image = loadImage("test.bmp");
printf("Enter the number of pixels in the x axis: ");
scanf("%d", &image.width);
printf("Enter the number of pixels in the y axis: ");
scanf("%d", &image.height);
for (i=0;i<image.width; i++)
for (j=0;j<image.height; j++){
RGB pixel = image.pixels[i][j];
pixel.R = pixel.R * 0.299;
pixel.G = pixel.G * 0.587;
pixel.B = pixel.B * 0.114;
image.pixels[i][j] = pixel;
}
saveImage("modified_test.bmp", image);
}
saveImage,loadImage和struct RGB已在头文件中定义。目标是将图像转换为灰度
答案 0 :(得分:3)
for (i=0;i<image.width; i++)
for (j=0;i<image.height; j++){
// i ???
您的意思是j < image.height
吗?