#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 and struct RGB have been defined in the header files. The objective is to turn an image into greyscale
saveImage,loadImage和struct RGB已在头文件中定义。目标是将图像转换为灰度
1 个解决方案
#1
3
for (i=0;i<image.width; i++)
for (j=0;i<image.height; j++){
// i ???
Do you mean j < image.height
?
你的意思是j
#1
3
for (i=0;i<image.width; i++)
for (j=0;i<image.height; j++){
// i ???
Do you mean j < image.height
?
你的意思是j