Пример #1
0
def generate_prediction(AL, BL, CL, AH, CH):
    flow_AL_BL = motion_estimation(AL, BL)
    flow_CL_BL = motion_estimation(CL, BL)
    BAH = estimate_frame(AH, flow_AL_BL)
    BCH = estimate_frame(CH, flow_CL_BL)
    BAL = estimate_frame(AL, flow_AL_BL)
    BCL = estimate_frame(CL, flow_CL_BL)
    EAL = BL - BAL
    ECL = BL - BCL
    SAL = 1 / (1 + abs(EAL))
    SCL = 1 / (1 + abs(ECL))
    return (BAH * SAL + BCH * SCL) / (SAL + SCL)
Пример #2
0
    def __backward_butterfly(self, aL, aH, bL, residue_bH, cL, cH):
        '''Backward MCDWT butterfly.

        Input:
        -----

        aL, aH, bL, residue_bH, cL, cH: array[y, x, component], the
        \tilde{b} image.

        Output:
        ------

        bH: array[y, x, component], the high-frequencies of the image
        b.

        '''

        #AL = self.dwt.backward((aL, self.zero_H))
        #BL = self.dwt.backward((bL, self.zero_H))
        #CL = self.dwt.backward((cL, self.zero_H))
        AH = self.dwt.backward((self.zero_L, aH))
        residue_BH = self.dwt.backward((self.zero_L, residue_bH))
        CH = self.dwt.backward((self.zero_L, cH))
        #prediction_BH  = predictor.generate_prediction(AL, BL, CL, AH, CH)

        #prediction_BH = predictor.generate_rediction(aL, bL, cL, aH, cH)
        flow_aL_bL = motion_estimation(aL, bL)
        flow_cL_bL = motion_estimation(cL, bL)
        c1 = pywt.idwt2((flow_aL_bL[:, :, 0], (None, None, None)),
                        wavelet='haar',
                        mode='per')
        c2 = pywt.idwt2((flow_aL_bL[:, :, 0], (None, None, None)),
                        wavelet='haar',
                        mode='per')
        Flow_aL_bL = np.stack((c1, c2), axis=-1)
        c1 = pywt.idwt2((flow_cL_bL[:, :, 0], (None, None, None)),
                        wavelet='haar',
                        mode='per')
        c2 = pywt.idwt2((flow_cL_bL[:, :, 0], (None, None, None)),
                        wavelet='haar',
                        mode='per')
        Flow_cL_bL = np.stack((c1, c2), axis=-1)
        BAH = estimate_frame(AH, Flow_aL_bL)
        BCH = estimate_frame(CH, Flow_cL_bL)
        prediction_BH = (BAH + BCH) / 2
        BH = residue_BH + prediction_BH
        bH = self.dwt.forward(BH)
        return bH[1]
Пример #3
0
    def __forward_butterfly(self, aL, aH, bL, bH, cL, cH):
        '''Forward MCDWT butterfly.

        Input:
        -----

        aL, aH, bL, bH, cL, cH: array[y, x, component], the decomposition of
        the images a, b and c.

        Output:
        ------

        residue_bH: array[y, x, component], the residue of the
        high-requency information of the image b.

        '''

        #AL = self.dwt.backward((aL, self.zero_H))
        #BL = self.dwt.backward((bL, self.zero_H))
        #CL = self.dwt.backward((cL, self.zero_H))
        AH = self.dwt.backward((self.zero_L, aH))
        BH = self.dwt.backward((self.zero_L, bH))
        CH = self.dwt.backward((self.zero_L, cH))
        #prediction_BH  = predictor.generate_prediction(AL, BL, CL, AH, CH)
        #prediction_BH = predictor.generate_prediction(aL, bL, cL, aH, cH)
        flow_aL_bL = motion_estimation(aL, bL)
        flow_cL_bL = motion_estimation(cL, bL)
        c1 = pywt.idwt2((flow_aL_bL[:, :, 0], (None, None, None)),
                        wavelet='haar',
                        mode='per')
        c2 = pywt.idwt2((flow_aL_bL[:, :, 0], (None, None, None)),
                        wavelet='haar',
                        mode='per')
        Flow_aL_bL = np.stack((c1, c2), axis=-1)
        c1 = pywt.idwt2((flow_cL_bL[:, :, 0], (None, None, None)),
                        wavelet='haar',
                        mode='per')
        c2 = pywt.idwt2((flow_cL_bL[:, :, 0], (None, None, None)),
                        wavelet='haar',
                        mode='per')
        Flow_cL_bL = np.stack((c1, c2), axis=-1)
        BAH = estimate_frame(AH, Flow_aL_bL)
        BCH = estimate_frame(CH, Flow_cL_bL)
        prediction_BH = (BAH + BCH) / 2
        residue_BH = BH - prediction_BH
        residue_bH = self.dwt.forward(residue_BH)
        return residue_bH[1]
Пример #4
0
    def __backward_butterfly(self, aL, aH, bL, residue_bH, cL, cH):
        AL = self.dwt.backward((aL, self.zero_H))
        BL = self.dwt.backward((bL, self.zero_H))
        CL = self.dwt.backward((cL, self.zero_H))
        AH = self.dwt.backward((self.zero_L, aH))
        residue_BH = self.dwt.backward((self.zero_L, residue_bH))
        CH = self.dwt.backward((self.zero_L, cH))
        '''
        Cálculo BHA, BLA, BHC, BLC optimizado
        '''
        flow = motion_estimation(AL, BL)
        BHA = estimate_frame(AH, flow)
        BLA = estimate_frame(AL, flow)
        flow = motion_estimation(CL, BL)
        BHC = estimate_frame(CH, flow)
        BLC = estimate_frame(CL, flow)

        prediction_BH = defprediction.calcula_prediction()

        BH = residue_BH + prediction_BH
        bH = self.dwt.forward(BH)
        return bH[1]
Пример #5
0
    def __forward_butterfly(self, aL, aH, bL, bH, cL, cH):
        '''Motion compensated forward MCDWT butterfly.

        Input:
        -----

        aL, aH, bL, bH, cL, cH: array[y, x, component], the decomposition of
        the images a, b and c.

        Output:
        ------

        residue_bH: array[y, x, component], the base of the decomposition of
        the residue fot the image b.

        '''

        AL = self.dwt.backward((aL, self.zero_H))
        BL = self.dwt.backward((bL, self.zero_H))
        CL = self.dwt.backward((cL, self.zero_H))
        AH = self.dwt.backward((self.zero_L, aH))
        BH = self.dwt.backward((self.zero_L, bH))
        CH = self.dwt.backward((self.zero_L, cH))
        '''
        Cálculo BHA, BLA, BHC, BLC optimizado
        '''
        flow = motion_estimation(AL, BL)
        BHA = estimate_frame(AH, flow)
        BLA = estimate_frame(AL, flow)
        flow = motion_estimation(CL, BL)
        BHC = estimate_frame(CH, flow)
        BLC = estimate_frame(CL, flow)

        prediction_BH = defprediction.calcula_prediction()

        residue_BH = BH - prediction_BH
        residue_bH = self.dwt.forward(residue_BH)
        return residue_bH[1]
Пример #6
0
def generate_prediction(AL, BL, CL, AH, CH):
    flow_CL_BL = motion_estimation(CL, BL)
    BCH = estimate_frame(CH, flow_CL_BL)
    return BCH
Пример #7
0
def generate_prediction(AL, BL, CL, AH, CH):
    flow_AL_BL = motion_estimation(AL, BL)
    BAH = estimate_frame(AH, flow_AL_BL)
    return BAH