modules/thermal.py
def reg_avg_denoise(imstack, ecc_mats=None):
    '''
        Denoise a thermal stack by registering and averaging.
        
        Inputs:

        Outputs:
            im_denoised: Denoised image
    '''
    nimg, H, W = imstack.shape
    # if ecc_mats is none, register the stack
    if ecc_mats is None:
        ecc_mats = motion.register_stack(imstack, (H, W))[:, :2, :]
    
     # Now warp image back to reference and average
    ecc_inv = motion.invert_regstack(ecc_mats)
    imten = torch.tensor(imstack.astype(np.float32))[:, None, ...]
    ecc_ten = torch.tensor(ecc_inv.astype(np.float32))
    
    imwarped = kornia.warp_affine(imten, ecc_ten, (H, W), flags='bilinear')
    im_denoised = imwarped.mean(0)[0, ...].numpy()
    weights = (imwarped > 0).type(torch.float32).mean(0)[0, ...].numpy()
    weights[weights == 0] = 1
    
    im_denoised /= weights

    return im_denoised

        Denoise a thermal stack by registering and averaging.
        
        Inputs:

        Outputs:
            im_denoised: Denoised image
    
Denoise a thermal stack by registering and averaging.
Inputs.

Denoised image
Denoise a thermal stack by registering and averaging . Inputs . Denoised image
def reg_avg_denoise(imstack, ecc_mats=None):
    nimg, H, W = imstack.shape
    if ecc_mats is None:
        ecc_mats = motion.register_stack(imstack, (H, W))[:, :2, :]
    ecc_inv = motion.invert_regstack(ecc_mats)
    imten = torch.tensor(imstack.astype(np.float32))[:, None, ...]
    ecc_ten = torch.tensor(ecc_inv.astype(np.float32))
    imwarped = kornia.warp_affine(imten, ecc_ten, (H, W), flags='bilinear')
    im_denoised = imwarped.mean(0)[0, ...].numpy()
    weights = (imwarped > 0).type(torch.float32).mean(0)[0, ...].numpy()
    weights[weights == 0] = 1
    im_denoised /= weights
    return im_denoised
def reg_avg_denoise ( imstack , ecc_mats = None ) : nimg , H , W = imstack . shape if ecc_mats is None : ecc_mats = motion . register_stack ( imstack , ( H , W ) ) [ : , : 2 , : ] ecc_inv = motion . invert_regstack ( ecc_mats ) imten = torch . tensor ( imstack . astype ( np . float32 ) ) [ : , None , ... ] ecc_ten = torch . tensor ( ecc_inv . astype ( np . float32 ) ) imwarped = kornia . warp_affine ( imten , ecc_ten , ( H , W ) , flags = 'bilinear' ) im_denoised = imwarped . mean ( 0 ) [ 0 , ... ] . numpy ( ) weights = ( imwarped > 0 ) . type ( torch . float32 ) . mean ( 0 ) [ 0 , ... ] . numpy ( ) weights [ weights == 0 ] = 1 im_denoised /= weights return im_denoised
Denoise a thermal stack by registering and averaging.
Denoise a thermal stack by registering and averaging .
'''
        Denoise a thermal stack by registering and averaging.
        
        Inputs:

        Outputs:
            im_denoised: Denoised image
    ''' # if ecc_mats is none, register the stack # Now warp image back to reference and average
imstack
ecc_mats