File size: 826 Bytes
6e70c4a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
"""
-------------------------------------------------
   File Name:   dct
   Author :      wenbo
   date:         12/4/2019
   Description :
-------------------------------------------------
   Change Activity:
                   12/4/2019:
-------------------------------------------------
"""
__author__ = 'wenbo'

from torch import nn
from ._dct import LinearDCT, apply_linear_2d


class DCT_Lowfrequency(nn.Module):
    def __init__(self, size=256, fLimit=50):
        super(DCT_Lowfrequency, self).__init__()
        self.fLimit = fLimit
        self.dct = LinearDCT(size, type='dct', norm='ortho')
        self.dctTransformer = lambda x: apply_linear_2d(x, self.dct)

    def forward(self, x):
        x = self.dctTransformer(x)
        x = x[:, :, :self.fLimit, :self.fLimit]
        return x