:param h: height :param w: width :return: normalized distance to image border, wtith min distance = 0 at border and max dist = 0.5 at image center
(self, h, w)
| 690 | return arr |
| 691 | |
| 692 | def delta_border(self, h, w): |
| 693 | """ |
| 694 | :param h: height |
| 695 | :param w: width |
| 696 | :return: normalized distance to image border, |
| 697 | wtith min distance = 0 at border and max dist = 0.5 at image center |
| 698 | """ |
| 699 | lower_right_corner = torch.tensor([h - 1, w - 1]).view(1, 1, 2) |
| 700 | arr = self.meshgrid(h, w) / lower_right_corner |
| 701 | dist_left_up = torch.min(arr, dim=-1, keepdims=True)[0] |
| 702 | dist_right_down = torch.min(1 - arr, dim=-1, keepdims=True)[0] |
| 703 | edge_dist = torch.min(torch.cat([dist_left_up, dist_right_down], dim=-1), dim=-1)[0] |
| 704 | return edge_dist |
| 705 | |
| 706 | def get_weighting(self, h, w, Ly, Lx, device): |
| 707 | weighting = self.delta_border(h, w) |