<small id='kUPwB'></small><noframes id='kUPwB'>

    1. <tfoot id='kUPwB'></tfoot>
          <bdo id='kUPwB'></bdo><ul id='kUPwB'></ul>
      1. <i id='kUPwB'><tr id='kUPwB'><dt id='kUPwB'><q id='kUPwB'><span id='kUPwB'><b id='kUPwB'><form id='kUPwB'><ins id='kUPwB'></ins><ul id='kUPwB'></ul><sub id='kUPwB'></sub></form><legend id='kUPwB'></legend><bdo id='kUPwB'><pre id='kUPwB'><center id='kUPwB'></center></pre></bdo></b><th id='kUPwB'></th></span></q></dt></tr></i><div id='kUPwB'><tfoot id='kUPwB'></tfoot><dl id='kUPwB'><fieldset id='kUPwB'></fieldset></dl></div>
        <legend id='kUPwB'><style id='kUPwB'><dir id='kUPwB'><q id='kUPwB'></q></dir></style></legend>

        scipy.ndimage.interpolation.rotate 之后旋转的图像坐标?

        时间:2023-07-03

        <small id='Bij35'></small><noframes id='Bij35'>

      2. <tfoot id='Bij35'></tfoot>

          <legend id='Bij35'><style id='Bij35'><dir id='Bij35'><q id='Bij35'></q></dir></style></legend>

            <i id='Bij35'><tr id='Bij35'><dt id='Bij35'><q id='Bij35'><span id='Bij35'><b id='Bij35'><form id='Bij35'><ins id='Bij35'></ins><ul id='Bij35'></ul><sub id='Bij35'></sub></form><legend id='Bij35'></legend><bdo id='Bij35'><pre id='Bij35'><center id='Bij35'></center></pre></bdo></b><th id='Bij35'></th></span></q></dt></tr></i><div id='Bij35'><tfoot id='Bij35'></tfoot><dl id='Bij35'><fieldset id='Bij35'></fieldset></dl></div>

            • <bdo id='Bij35'></bdo><ul id='Bij35'></ul>
                    <tbody id='Bij35'></tbody>
                  本文介绍了scipy.ndimage.interpolation.rotate 之后旋转的图像坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个从 FITS 文件中读取的图像的 numpy 数组.我使用 scipy.ndimage.interpolation.rotate 将它旋转了 N 度.然后我想弄清楚原始非旋转框架中的某个点 (x,y) 在旋转图像中的最终位置——即旋转的框架坐标 (x',y') 是什么?

                  这应该是一个非常简单的旋转矩阵问题,但是如果我使用通常的基于数学或编程的旋转方程,新的 (x',y') 不会以它们原来的位置结束.我怀疑这也与需要平移矩阵有关,因为 scipy 旋转函数基于原点 (0,0) 而不是图像数组的实际中心.

                  谁能告诉我如何获得旋转的框架(x',y')?例如,您可以使用

                  from scipy import misc从 scipy.ndimage 导入旋转data_orig = misc.face()data_rot = rotate(data_orig,66) # 数据数组x0,y0 = 580,300 # 左眼;(xrot,yrot) 应该指向那里

                  附:以下两个相关问题的答案对我没有帮助:

                  • I have a numpy array for an image that I read in from a FITS file. I rotated it by N degrees using scipy.ndimage.interpolation.rotate. Then I want to figure out where some point (x,y) in the original non-rotated frame ends up in the rotated image -- i.e., what are the rotated frame coordinates (x',y')?

                    This should be a very simple rotation matrix problem but if I do the usual mathematical or programming based rotation equations, the new (x',y') do not end up where they originally were. I suspect this has something to do with needing a translation matrix as well because the scipy rotate function is based on the origin (0,0) rather than the actual center of the image array.

                    Can someone please tell me how to get the rotated frame (x',y')? As an example, you could use

                    from scipy import misc
                    from scipy.ndimage import rotate
                    data_orig = misc.face()
                    data_rot = rotate(data_orig,66) # data array
                    x0,y0 = 580,300 # left eye; (xrot,yrot) should point there
                    

                    P.S. The following two related questions' answers do not help me:

                    • Find new coordinates of a point after rotation

                    • New coordinates after image rotation using scipy.ndimage.rotate

                    解决方案

                    As usual with rotations, one needs to translate to the origin, then rotate, then translate back. Here, we can take the center of the image as origin.

                    import numpy as np
                    import matplotlib.pyplot as plt
                    from scipy import misc
                    from scipy.ndimage import rotate
                    
                    data_orig = misc.face()
                    x0,y0 = 580,300 # left eye; (xrot,yrot) should point there
                    
                    def rot(image, xy, angle):
                        im_rot = rotate(image,angle) 
                        org_center = (np.array(image.shape[:2][::-1])-1)/2.
                        rot_center = (np.array(im_rot.shape[:2][::-1])-1)/2.
                        org = xy-org_center
                        a = np.deg2rad(angle)
                        new = np.array([org[0]*np.cos(a) + org[1]*np.sin(a),
                                -org[0]*np.sin(a) + org[1]*np.cos(a) ])
                        return im_rot, new+rot_center
                    
                    
                    fig,axes = plt.subplots(2,2)
                    
                    axes[0,0].imshow(data_orig)
                    axes[0,0].scatter(x0,y0,c="r" )
                    axes[0,0].set_title("original")
                    
                    for i, angle in enumerate([66,-32,90]):
                        data_rot, (x1,y1) = rot(data_orig, np.array([x0,y0]), angle)
                        axes.flatten()[i+1].imshow(data_rot)
                        axes.flatten()[i+1].scatter(x1,y1,c="r" )
                        axes.flatten()[i+1].set_title("Rotation: {}deg".format(angle))
                    
                    plt.show()
                    

                    这篇关于scipy.ndimage.interpolation.rotate 之后旋转的图像坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Pygame-同时旋转精灵并跟随路径 下一篇:如何在极坐标 matplotlib 图中旋转刻度标签?

                  相关文章

                • <small id='DxGl5'></small><noframes id='DxGl5'>

                  <legend id='DxGl5'><style id='DxGl5'><dir id='DxGl5'><q id='DxGl5'></q></dir></style></legend>
                    <bdo id='DxGl5'></bdo><ul id='DxGl5'></ul>

                      <tfoot id='DxGl5'></tfoot>
                      <i id='DxGl5'><tr id='DxGl5'><dt id='DxGl5'><q id='DxGl5'><span id='DxGl5'><b id='DxGl5'><form id='DxGl5'><ins id='DxGl5'></ins><ul id='DxGl5'></ul><sub id='DxGl5'></sub></form><legend id='DxGl5'></legend><bdo id='DxGl5'><pre id='DxGl5'><center id='DxGl5'></center></pre></bdo></b><th id='DxGl5'></th></span></q></dt></tr></i><div id='DxGl5'><tfoot id='DxGl5'></tfoot><dl id='DxGl5'><fieldset id='DxGl5'></fieldset></dl></div>