coastalimagelib/argusIO.py
def deBayerRawFrame(self):
        '''
        deBayers a raw frame using Argus framework, adapted from
        original Matlab code from John Stanley

        Attributes:
            self.imGray:
        
        '''

        im = np.zeros(np.shape(self.raw))
        imGray = np.zeros(np.shape(self.raw))
        imR = np.zeros(np.shape(self.raw))
        imB = np.zeros(np.shape(self.raw))
        imG = np.zeros(np.shape(self.raw))

        for ib in range(self.nFrames):

            print('DeBayering frame {}'.format(ib))
            frame = self.raw[:, :, ib]

            # python code adpoted from Argus framework
            Bmin = [1, 3]
            Rmin = [2, 2]
            Gmin = [2, 3, 3, 2]

            B = frame.copy()
            xx = np.arange(Bmin[0], self.h, 2)
            for j in range(Bmin[1], self.w - 1, 2):
                B[xx - 1, j - 1] = np.mean((B[xx - 1, j - 2], B[xx - 1, j]), axis=0)

            for i in range(Bmin[0] + 1, self.h - 1, 2):
                B[i - 1, :] = np.mean((B[i - 2, :], B[i, :]), axis=0)

            R = frame.copy()
            xx = np.arange(Rmin[0], self.h - 1, 2)
            for j in range(Rmin[1], self.w - 1, 2):
                R[xx - 1, j - 1] = np.mean((R[xx - 1, j - 2], R[xx - 1, j]), axis=0)
            for i in range(Rmin[0] + 1, self.h - 1, 2):
                R[i - 1, :] = np.mean((R[i - 2, :], R[i, :]), axis=0)

            G = frame.copy()
            for i in range(Gmin[0], self.h - 1, 2):
                for j in range(Gmin[1], self.w - 1, 2):
                    G[i - 1, j - 1] = np.mean((G[i - 2, j - 1], G[i, j - 1], G[i - 1, j], G[i - 1, j - 2]), axis=0)

            for i in range(Gmin[2], self.h - 1, 2):
                for j in range(Gmin[3], self.w - 1, 2):
                    G[i - 1, j - 1] = np.mean((G[i - 2, j - 1], G[i, j - 1], G[i - 1, j], G[i - 1, j - 2]), axis=0)

            rgbArray = np.zeros((2048, 2448, 3), 'uint8')
            rgbArray[..., 0] = R
            rgbArray[..., 1] = G
            rgbArray[..., 2] = B
            imGrayscale = cv2.cvtColor(rgbArray, cv2.COLOR_BGR2GRAY)

            imGray[:, :, ib] = imGrayscale

            self.imGray = imGray

        deBayers a raw frame using Argus framework, adapted from
        original Matlab code from John Stanley

        Attributes:
            self.imGray:
        
        
deBayers a raw frame using Argus framework, adapted from
original Matlab code from John Stanley
deBayers a raw frame using Argus framework adapted from original Matlab code from John Stanley
def deBayerRawFrame(self):
        im = np.zeros(np.shape(self.raw))
        imGray = np.zeros(np.shape(self.raw))
        imR = np.zeros(np.shape(self.raw))
        imB = np.zeros(np.shape(self.raw))
        imG = np.zeros(np.shape(self.raw))
        for ib in range(self.nFrames):
            print('DeBayering frame {}'.format(ib))
            frame = self.raw[:, :, ib]
            Bmin = [1, 3]
            Rmin = [2, 2]
            Gmin = [2, 3, 3, 2]
            B = frame.copy()
            xx = np.arange(Bmin[0], self.h, 2)
            for j in range(Bmin[1], self.w - 1, 2):
                B[xx - 1, j - 1] = np.mean((B[xx - 1, j - 2], B[xx - 1, j]), axis=0)
            for i in range(Bmin[0] + 1, self.h - 1, 2):
                B[i - 1, :] = np.mean((B[i - 2, :], B[i, :]), axis=0)
            R = frame.copy()
            xx = np.arange(Rmin[0], self.h - 1, 2)
            for j in range(Rmin[1], self.w - 1, 2):
                R[xx - 1, j - 1] = np.mean((R[xx - 1, j - 2], R[xx - 1, j]), axis=0)
            for i in range(Rmin[0] + 1, self.h - 1, 2):
                R[i - 1, :] = np.mean((R[i - 2, :], R[i, :]), axis=0)
            G = frame.copy()
            for i in range(Gmin[0], self.h - 1, 2):
                for j in range(Gmin[1], self.w - 1, 2):
                    G[i - 1, j - 1] = np.mean((G[i - 2, j - 1], G[i, j - 1], G[i - 1, j], G[i - 1, j - 2]), axis=0)
            for i in range(Gmin[2], self.h - 1, 2):
                for j in range(Gmin[3], self.w - 1, 2):
                    G[i - 1, j - 1] = np.mean((G[i - 2, j - 1], G[i, j - 1], G[i - 1, j], G[i - 1, j - 2]), axis=0)
            rgbArray = np.zeros((2048, 2448, 3), 'uint8')
            rgbArray[..., 0] = R
            rgbArray[..., 1] = G
            rgbArray[..., 2] = B
            imGrayscale = cv2.cvtColor(rgbArray, cv2.COLOR_BGR2GRAY)
            imGray[:, :, ib] = imGrayscale
            self.imGray = imGray
def deBayerRawFrame ( self ) : im = np . zeros ( np . shape ( self . raw ) ) imGray = np . zeros ( np . shape ( self . raw ) ) imR = np . zeros ( np . shape ( self . raw ) ) imB = np . zeros ( np . shape ( self . raw ) ) imG = np . zeros ( np . shape ( self . raw ) ) for ib in range ( self . nFrames ) : print ( 'DeBayering frame {}' . format ( ib ) ) frame = self . raw [ : , : , ib ] Bmin = [ 1 , 3 ] Rmin = [ 2 , 2 ] Gmin = [ 2 , 3 , 3 , 2 ] B = frame . copy ( ) xx = np . arange ( Bmin [ 0 ] , self . h , 2 ) for j in range ( Bmin [ 1 ] , self . w - 1 , 2 ) : B [ xx - 1 , j - 1 ] = np . mean ( ( B [ xx - 1 , j - 2 ] , B [ xx - 1 , j ] ) , axis = 0 ) for i in range ( Bmin [ 0 ] + 1 , self . h - 1 , 2 ) : B [ i - 1 , : ] = np . mean ( ( B [ i - 2 , : ] , B [ i , : ] ) , axis = 0 ) R = frame . copy ( ) xx = np . arange ( Rmin [ 0 ] , self . h - 1 , 2 ) for j in range ( Rmin [ 1 ] , self . w - 1 , 2 ) : R [ xx - 1 , j - 1 ] = np . mean ( ( R [ xx - 1 , j - 2 ] , R [ xx - 1 , j ] ) , axis = 0 ) for i in range ( Rmin [ 0 ] + 1 , self . h - 1 , 2 ) : R [ i - 1 , : ] = np . mean ( ( R [ i - 2 , : ] , R [ i , : ] ) , axis = 0 ) G = frame . copy ( ) for i in range ( Gmin [ 0 ] , self . h - 1 , 2 ) : for j in range ( Gmin [ 1 ] , self . w - 1 , 2 ) : G [ i - 1 , j - 1 ] = np . mean ( ( G [ i - 2 , j - 1 ] , G [ i , j - 1 ] , G [ i - 1 , j ] , G [ i - 1 , j - 2 ] ) , axis = 0 ) for i in range ( Gmin [ 2 ] , self . h - 1 , 2 ) : for j in range ( Gmin [ 3 ] , self . w - 1 , 2 ) : G [ i - 1 , j - 1 ] = np . mean ( ( G [ i - 2 , j - 1 ] , G [ i , j - 1 ] , G [ i - 1 , j ] , G [ i - 1 , j - 2 ] ) , axis = 0 ) rgbArray = np . zeros ( ( 2048 , 2448 , 3 ) , 'uint8' ) rgbArray [ ... , 0 ] = R rgbArray [ ... , 1 ] = G rgbArray [ ... , 2 ] = B imGrayscale = cv2 . cvtColor ( rgbArray , cv2 . COLOR_BGR2GRAY ) imGray [ : , : , ib ] = imGrayscale self . imGray = imGray
deBayers a raw frame using Argus framework, adapted from
original Matlab code from John Stanley
deBayers a raw frame using Argus framework adapted from original Matlab code from John Stanley
'''
        deBayers a raw frame using Argus framework, adapted from
        original Matlab code from John Stanley

        Attributes:
            self.imGray:
        
        ''' # python code adpoted from Argus framework
self
self.imGray
None