【发布时间】:2022-01-19 14:59:01
【问题描述】:
我有一张这样的照片,用 Google 街景应用拍摄并裁剪到上半部分:
我使用Gimp polar coordinates filter 来获取这个新图像:
我想在 R 中做同样的事情,保留所有像素值信息。
Here我发现了一个类似的问题,但结果并不是我所需要的(转换的中心是一个角落)。调整后的代码(弧度有问题)是:
# Load the image
library(png)
library(RCurl)
d <- readPNG( getBinaryURL( "http://i.stack.imgur.com/rMR3C.png" ) )
image(d)
x0 = as.vector(col(d))
y0 = as.vector(row(d))
r = sqrt( (x0^2) + (y0^2) ) #x
a = atan(y0/x0) * 215 / (pi/2) #y
m = as.matrix(data.frame(y=a, x=r))
m = round(m)
m[m>215] = NA
m[m==0] = NA
xn = d[m]
xn = matrix(xn, 215, 215)
image(xn)
该问题的答案扩展了该问题并显示了执行极坐标到笛卡尔转换的代码,但我无法执行相反的操作。
【问题讨论】:
标签: r image-processing polar-coordinates