R光栅旋转图像而不改变它们的大小 [英] R raster rotating images and not changing their size

查看:64
本文介绍了R光栅旋转图像而不改变它们的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下旋转图像的代码.但是旋转后的图像具有不同的尺寸.我们如何确保旋转后的图像具有相同的尺寸?

I have below code which rotates an image. But the rotated image has different dimensions. How could we ensure that the rotated images has same dimensions?

即如果原始图像有 50 行 30 列,那么旋转后的图像应该有 30 行 50 列.

i.e. if the original image has 50 rows and 30 columns then the rotated image should have 30 rows and 50 columns.

library(raster)
r1 <- brick("watch1.JPG")#please use any jpg image
plotRGB(r1)
png("SaveThisPlot.png")
plotRGB(t(flip(r1, 2)))
dev.off()

推荐答案

png("SaveThisPlot.png",width=nrow(r1),height=ncol(r1))

这篇关于R光栅旋转图像而不改变它们的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆