简体   繁体   English

SciKit图像转换

[英]SciKit-Image Transformation

Hello I have a question regarding the sciKit image transform module: 您好,我对sciKit图像转换模块有疑问:

I am trying to find the optimal transform parameters that will flatten my images. 我正在尝试找到最佳的变换参数,以使图像变平。 Allowed is up to cubic transform ie 20 parameters. 最多允许三次变换,即20个参数。 I want an initial guess for my third order polynomial which shall be deduced from the already obtained 2nd order polynomial. 我想对我的三阶多项式进行初步猜测,该猜测应从已经获得的二阶多项式中推导。 However I am having troubles understanding which parameters assign where: 但是我很难理解哪些参数分配到哪里:

import numpy as np
import matplotlib.pyplot as plt
from skimage.transform import warp
from skimage.transform import AffineTransform
from skimage.transform import PolynomialTransform

def polynomialTransform(a0,a1,a2,a3,a4,a5,b0,b1,b2,b3,b4,b5):    
    array = np.zeros((2,6))
    array[0][0] = a0
    array[0][1] = a1
    array[0][2] = a2
    array[0][3] = a3
    array[0][4] = a4
    array[0][5] = a5
    array[1][0] = b0
    array[1][1] = b1
    array[1][2] = b2
    array[1][3] = b3
    array[1][4] = b4
    array[1][5] = b5
    return(PolynomialTransform(array))

def polynomialTransform2(a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9):    
    array = np.zeros((2,10))
    array[0][0] = a0
    array[0][1] = a1
    array[0][2] = a2
    array[0][3] = a3
    array[0][4] = a4
    array[0][5] = a5
    array[0][2] = a6
    array[0][3] = a7
    array[0][4] = a8
    array[0][5] = a9
    array[1][0] = b0
    array[1][1] = b1
    array[1][2] = b2
    array[1][3] = b3
    array[1][4] = b4
    array[1][5] = b5
    array[1][2] = b6
    array[1][3] = b7
    array[1][4] = b8
    array[1][5] = b9
    return(PolynomialTransform(array))

Now I am trying to understand which parameters from 2nd order corresponds to which coefficients in the third order polynomial. 现在,我试图了解二阶中的哪些参数对应于三阶多项式中的哪些系数。 I have run several tests: 我已经运行了几个测试:

    def doTransfrom(cubeROI):  #Enter any image in the format of an n*m numpy array
        x0 = np.asarray([1,1,0,0,0,0,0,0,1,1,1,1])

        pCubic = np.asarray([1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1])

        quadratic=warp(cubeROI,polynomialTransform(x0[0],x0[1],x0[2],x0[3],x0[4],x0[5],x0[6],x0[7],x0[8],x0[9],x0[10],x0[11]))

        cubic=warp(cubeROI,polynomialTransform2(pCubic[0],pCubic[1],pCubic[2],pCubic[3],pCubic[4],pCubic[5],pCubic[6],pCubic[7],pCubic[8],pCubic[9],pCubic[10],pCubic[11],pCubic[12],pCubic[13],pCubic[14],pCubic[15],pCubic[16],pCubic[17],pCubic[18],pCubic[19]))


        plt.imshow(quadratic)
        plt.show()
        plt.imshow(cubic)
        plt.show()

As you can see the first 2 and the last 4 parameters correspond to one another... However I am struggling to figure out the 5 parameters that are left from the quadratic transform. 如您所见,前2个参数和后4个参数彼此对应...但是,我在努力找出二次变换剩下的5个参数。 In fact I have the feeling that none of the parameters that come after 'a1' do anything - Thus I believe that my problem originates in the way I feed my an/bn s into PolynomialTrasnsform ! 实际上,我感觉到'a1'之后的参数都不起作用- 因此,我认为我的问题源于将an / bn馈入PolynomialTrasnsform的方式 What am I doing wrong?! 我究竟做错了什么?!

What am I really trying to do: For better understanding - I am trying to find a coordinate system for which the difference of a set of images from its median is minimal: 我真正想做的是:为了更好地理解-我试图找到一个坐标系,该图像组的图像与其中值的差异最小:

min_(an,bn): chi^2 = (Delta - I(f(x,y,a_n,b_n))^2

二次变换 三次变换

Hello I have resolved my issue: 您好我已经解决了我的问题:

If one where to pass the transformation parameters a_n, b_n like I defined them the correct sorting is: 如果像我定义的那样将转换参数a_n,b_n传递到哪里,则正确的排序是:

2nd order poly: 二阶多边形:

[a0,a1,a2,a3,a4,a5,b0,b1,b2,b3,b4,b5]

3rd order poly: 三阶多边形:

[a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9]

The values that one wants to inherit from the 2nd order polynomial to the 3rd are denoted with a second indice, which is the order of the 2nd order polynomial eg a00(3rd order) = a0(2nd order): 要从2阶多项式继承到3阶的值用第二个索引表示,它是2阶多项式的阶,例如a00(3rd order)= a0(2nd order):

initial guess for 3rd order polynomial: 三阶多项式的初始猜测:

[a00,a11,a2,a3,a4,a5,a62,a73,a84,a95,b00,b11,b2,b3,b4,b5,b62,b73,b84,b95]

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

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