SEU-CT-Recon / crip

CT Recon in Python: An all-in-one tool for Data IO, Pre/Post-process, Physics, Dual Energy, Low Dose and everything.
https://seu-ct-recon.github.io/crip
MIT License
36 stars 7 forks source link

You want this? Do this! #14

Open CandleHouse opened 11 months ago

CandleHouse commented 11 months ago

Get decomposition coefficient with physical experiment without spectrum! Please integrate this!

def deDecompGetCoeff(lowProj: TwoOrThreeD, highProj: TwoOrThreeD, 
                     len1: TwoOrThreeD, len2: TwoOrThreeD) -> Tuple[NDArray, NDArray]:
    '''
        Calculate the decomposing coefficient (Order 2 with bias term) of dual-energy onto two material length.
    '''

    def deCalcBetaGamma(A1, A2, LComb):
        A1Square = A1.T**2
        A2Square = A2.T**2
        A1A2 = (A1 * A2).T
        A1 = A1.T
        A2 = A2.T
        Ones = np.ones((A1.T.shape[0]))
        A = np.array([A1Square, A2Square, A1A2, A1, A2, Ones]).T

        return np.linalg.pinv(A) @ LComb

    beta, gamma = deCalcBetaGamma(lowProj.flatten(), highProj.flatten(), 
                                  np.array([len1.flatten(), len2.flatten()]).T).T

    return beta, gamma
z0gSh1u commented 11 months ago

6

Ruachmaninov commented 11 months ago

6