问题
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?
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()
回答1:
png("SaveThisPlot.png",width=nrow(r1),height=ncol(r1))
来源:https://stackoverflow.com/questions/31814873/r-raster-rotating-images-and-not-changing-their-size