Skip to content

Commit c742b47

Browse files
authored
Make smoothing in gNCC optional (#390)
1 parent 176e9c8 commit c742b47

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

diffdrr/metrics.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ def __init__(self, sigma: float):
8585
self.filter.weight = torch.nn.Parameter(G, requires_grad=False)
8686

8787
def forward(self, img):
88-
x = gaussian_blur(img, 5, self.sigma)
88+
x = img
89+
if self.sigma > 0:
90+
kernel_size = int(6 * self.sigma + 1) | 1
91+
x = gaussian_blur(img, kernel_size, self.sigma)
8992
x = self.filter(x)
9093
return x
9194

notebooks/api/05_metrics.ipynb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,10 @@
179179
" self.filter.weight = torch.nn.Parameter(G, requires_grad=False)\n",
180180
"\n",
181181
" def forward(self, img):\n",
182-
" x = gaussian_blur(img, 5, self.sigma)\n",
182+
" x = img\n",
183+
" if self.sigma > 0:\n",
184+
" kernel_size = int(6 * self.sigma + 1) | 1\n",
185+
" x = gaussian_blur(img, kernel_size, self.sigma)\n",
183186
" x = self.filter(x)\n",
184187
" return x"
185188
]

0 commit comments

Comments
 (0)