简体   繁体   English

笛卡尔图像到极坐标

[英]Cartesian image to polar coordinate

I know this question has already been answered a lot of time but i can't figure if what 'im doing is good or bad. 我知道这个问题已经回答了很多时间,但我无法确定“我在做什么是好还是坏”。

I got a file with defect position and image ID. 我有一个带有缺陷位置和图像ID的文件。 image size are 96*96. 图像大小为96 * 96。 Origin is (48,48) 起源是(48,48)

imgID  X        Y
1      5        6
1      87       76
2      45       23

From this i calculate R and T 由此我计算R和T.

x,y = df.X-48,df.Y-48
r = np.sqrt(x**2+y**2)
t = np.arctan2(y,x)
df["r"]=r
df["t"]=t

Then i create empty matrix of size 96*96 for each image, and for image 1 (for exemple) i assign value 0 at each coordinate (R,T) 然后我为每个图像创建大小为96 * 96的空矩阵,对于图像1(例如),我在每个坐标(R,T)处分配值0

When i plot my matrix my result are strange.. Am i missing something important? 当我绘制我的矩阵时,我的结果很奇怪..我错过了一些重要的东西吗?

Not sure if you are insistent on a Python solution, or you just want to get the job done. 不确定您是否坚持使用Python解决方案,或者您只是想完成工作。 If the former, please just ignore me and my answer will sink to the bottom. 如果是前者,请忽略我,我的答案会沉到底部。 If the latter, you can do that with ImageMagick which is installed on most Linux distros and is available for macOS and Windows. 如果是后者,你可以使用安装在大多数Linux发行版上的ImageMagick ,并且可用于macOS和Windows。

So, starting with this colorwheel.png : 所以,从这个colorwheel.png开始:

在此输入图像描述

Just use the following command in Terminal, or Command Prompt if on Windows: 只需在终端中使用以下命令,或在Windows上使用命令提示符:

magick colorwheel.png -distort depolar 0 result.png

在此输入图像描述

It's a little "off" because my input image is not exactly square or centred, but you get the idea :-) 它有点“关闭”,因为我的输入图像不是正方形或居中,但你明白了:-)

Replace -distort depolar with -distort polar to do the inverse transformation. -distort depolar -distort polar替换-distort depolar来进行逆变换。

For versions prior to v7, replace magick with convert in the commands above. 对于v7之前的版本,请在上面的命令中使用convert替换magick

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM