矩形换位算法C语言实现,变换并重新映射90°卷的等矩形图像

首先,我将我的研究导向imagemagick。我试过Fred ImageMagick scripts,但找不到任何人做我想做的事。此外,与Pano2VR相比,图像的处理时间显得非常长。

我指示我的调查OpenCV和libgnomonic。这是目前最有趣的方式。该库允许te用户转换投影(equirectangular为直线,反之亦然)或make equirectangular mapping transformation。我玩Norama-suite这包含一些脚本来处理图书馆。例如,我会将直线图像转换为等矩形图像,但是输出只是一个黑色背景图像(为什么?我没有找到答案)。

但是,这第二个链接可以解决我的问题。我有这样的形象:

7701a3d87c71a7154cc3e496b698005b.png

,我想将它转化到该图像

83ef2714190a5d6772003a2b633892ea.png

嗯,我不舒服C. 在所有我想我应该用这两个文件:

但我不知道如何。最重要的是,我想了解。

我是否正确?第一张图像上应用了什么转换?有没有办法用python或bash脚本来做到这一点?

恩,谢谢你的帮忙。

** python中的C编辑换位** 下面的代码没有工作,返回和IndexError。 但是我试图抓住并通过例外,图像的第一个右侧部分似乎没有改变。 import math

from PIL import Image

img = Image.open("img1.jpg")

img = img.convert('RGB')

pixel = img.load()

width, height = img.size

img2 = img.copy()

for y in xrange(height):

for x in xrange(width):

xx = 2*(y+0.5)/width - 1.0

yy = 2*(y+0.5)/ height - 1.0

lng = math.pi * xx

lat = 0.5 * math.pi * yy

# NOTE! These axes are transposed because that's what the question is about

Z = math.cos(lat) * math.cos(lng) # normally X

Y = math.cos(lat) * math.sin(lng) # normally Y

X = -math.sin(lat) # normally -Z

D = math.sqrt(X*X+Y*Y)

lat = math.atan2(Z, D) # ? normally lat = math.asin(Z)

lng = math.atan2(Y, X)

#ix and iy must be integers

ix = int((0.5 * lng/math.pi + 0.5) * width - 0.5)

iy = int((lat/math.pi + 0.5) * height - 0.5)

#not sure of this part to remap the image

newpixel = pixel[ix, iy]

img2.putpixel([(x+width/4) % width, y], newpixel)

#I tries as mentionned in the following code to invert x and y in the two previous lines but the index error out of range comes back

img2.show()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值