def get_gradient_kernel(self):
        gradient_block = nn.ModuleList()

        conv_x = Conv2d(1, 1, [1, 2], padding='SAME',
                        bias=False, weight=[[[[-1, 1]]]])
        gradient_block.append(conv_x)

        conv_y = Conv2d(1, 1, [2, 1], padding='SAME',
                        bias=False, weight=[[[[-1], [1]]]])
        gradient_block.append(conv_y)

        return gradient_block
Exemple #2
0
    def get_centered_gradient_kernel(self):
        centered_gradient_block = nn.ModuleList()

        conv_x = Conv2d(1, 1, [1, 3], padding='SAME', 
                        bias=False, weight=[[[[-0.5, 0, 0.5]]]])
        centered_gradient_block.append(conv_x)

        conv_y = Conv2d(1, 1, [3, 1], padding='SAME',
                        bias=False, weight=[[[[-0.5], [0], [0.5]]]])
        centered_gradient_block.append(conv_y)

        return centered_gradient_block
Exemple #3
0
    def get_divergence_kernel(self):
        divergence_block = nn.ModuleList() #[conv_x, conv_y]
        
        conv_x = Conv2d(1, 1, [1, 2], padding='SAME', 
                        bias=False, weight=[[[[-1, 1]]]])
        divergence_block.append(conv_x)

        conv_y = Conv2d(1, 1, [2, 1], padding='SAME', 
                        bias=False, weight=[[[[-1], [1]]]])
        divergence_block.append(conv_y)

        return divergence_block
    def get_gray_conv(self):
        gray_conv = Conv2d(3,
                           1, [1, 1],
                           bias=False,
                           padding='SAME',
                           weight=[[[[0.114]], [[0.587]], [[0.299]]]])

        return gray_conv
Exemple #5
0
 def get_gaussian_conv(self):
     gaussian_conv = Conv2d(1, 1, [5, 5], bias=False, padding='SAME',
                            weight=[[[[0.000874, 0.006976, 0.01386, 0.006976, 0.000874],
                                 [0.006976, 0.0557, 0.110656, 0.0557, 0.006976],
                                 [0.01386, 0.110656, 0.219833, 0.110656, 0.01386],
                                 [0.006976, 0.0557, 0.110656, 0.0557, 0.006976],
                                 [0.000874, 0.006976, 0.01386, 0.006976, 0.000874]]]])
     return gaussian_conv