旋转图像使其直立

Rotating the image to get it an upright position

我正在尝试可视化数字图像 5。初始代码:

image(matrix(data[,11552], nrow = 28, byrow = TRUE), col = gray(0:255/255))

看起来像下图:

当我使用代码对矩阵进行转置时:

image(t(matrix(data[,11552], nrow = 28, byrow = TRUE)), col = gray(0:255/255))

,看起来像:

如您所见,我仍然无法直立5。我怎样才能进一步旋转图像,使 5 处于直立位置?

data 的维度为:

[1]   784 11552

您可以尝试反转数据(使用 rev())而不是转置数据吗?

只是一个想法,因为 t() 水平和垂直翻转,所以 t(t(data)) = data

以下是您要的吗?

windows()
image(volcano)

windows()
image(volcano[nrow(volcano):1, ncol(volcano):1])

注意:我是 运行 这个 Windows。

编辑。

上面的代码水平和垂直翻转图像。如果只需要颠倒显示图像,只需反转列索引即可。

windows()
image(volcano[, ncol(volcano):1])