【发布时间】:2019-10-18 07:19:17
【问题描述】:
我的函数正在获取图像,我正在尝试将其向右或向左翻转。水平翻转。我试图做类似的事情,但不知道如何前进
图像的大小是整数高度和整数宽度,函数知道像素值。
这是我的代码:
void flip_hrizntal_pixels(struct Pixel **pixels, int height, int width)
{
//Stuck here don't know how flip those pixels
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
//pixels[i][j].red =
//pixels[i][j].green =
//pixels[i][j].blue =
}
}
}
这里是结构数据:
struct Pixel
{
unsigned char red;
unsigned char green;
unsigned char blue;
};
struct RGB_Image
{
long height;
long width;
long size;
struct Pixel **pixels;
};
我是这样调用这个函数的:
struct RGB_Image image;
int status = load_image(&image);
flip_hrizntal_pixels(image.pixels, image.height, image.width);
【问题讨论】:
-
您的内部循环需要将第一个像素与最后一个像素交换,并在将行的前半部分与后半部分交换时停止。这有帮助吗?
-
嗨,斯塔克,谢谢! ,对不起,我是 c 的新手,不知道该怎么做。
标签: c image-processing