File tree Expand file tree Collapse file tree 1 file changed +2
-14
lines changed Expand file tree Collapse file tree 1 file changed +2
-14
lines changed Original file line number Diff line number Diff line change 1
1
use crate :: core:: { ColourModel , Image } ;
2
+ use crate :: core:: padding:: * ;
2
3
use crate :: processing:: Error ;
3
4
use ndarray:: prelude:: * ;
4
5
use ndarray:: { s, Zip } ;
@@ -40,24 +41,11 @@ where
40
41
// Bit icky but handles fact that uncentred convolutions will cross the bounds
41
42
// otherwise
42
43
let ( row_offset, col_offset) = kernel_centre ( k_s[ 0 ] , k_s[ 1 ] ) ;
43
- // row_offset * 2 may not equal k_s[0] due to truncation
44
- let shape_ext = (
45
- self . shape ( ) [ 0 ] + row_offset * 2 ,
46
- self . shape ( ) [ 1 ] + col_offset * 2 ,
47
- self . shape ( ) [ 2 ] ,
48
- ) ;
49
44
let shape = ( self . shape ( ) [ 0 ] , self . shape ( ) [ 1 ] , self . shape ( ) [ 2 ] ) ;
50
45
51
46
if shape. 0 > 0 && shape. 1 > 0 {
52
47
let mut result = Self :: zeros ( shape) ;
53
-
54
- let mut tmp = Self :: zeros ( shape_ext) ;
55
- tmp. slice_mut ( s ! [
56
- row_offset..shape_ext. 0 - row_offset,
57
- col_offset..shape_ext. 1 - col_offset,
58
- ..
59
- ] )
60
- . assign ( & self ) ;
48
+ let tmp = self . pad ( ( row_offset, col_offset) , & ZeroPadding { } ) ;
61
49
62
50
Zip :: indexed ( tmp. windows ( kernel. dim ( ) ) ) . apply ( |( i, j, _) , window| {
63
51
let mult = & window * & kernel;
You can’t perform that action at this time.
0 commit comments