@@ -295,16 +295,17 @@ Generate an index-vector to be used for padding. `inds` specifies the image indi
295295"""
296296function padindex (border:: Pad , lo:: Integer , inds:: AbstractUnitRange , hi:: Integer )
297297 if border. style == :replicate
298- return vcat (fill (first (inds), lo), PinIndices (inds), fill (last (inds), hi))
298+ indsnew = vcat (fill (first (inds), lo), inds, fill (last (inds), hi))
299+ OffsetArray (indsnew, first (inds)- lo: last (inds)+ hi)
299300 elseif border. style == :circular
300301 return modrange (extend (lo, inds, hi), inds)
301302 elseif border. style == :symmetric
302- I = [inds; reverse (inds)]
303- r = modrange (extend (lo, inds, hi), 1 : 2 * length (inds ))
303+ I = OffsetArray ( [inds; reverse (inds)], ( 0 : 2 * length (inds) - 1 ) + first (inds))
304+ r = modrange (extend (lo, inds, hi), indices (I, 1 ))
304305 return I[r]
305306 elseif border. style == :reflect
306- I = [inds; last (inds)- 1 : - 1 : first (inds)+ 1 ]
307- return I[modrange (extend (lo, inds, hi), 1 : 2 * length (inds) - 2 )]
307+ I = OffsetArray ( [inds; last (inds)- 1 : - 1 : first (inds)+ 1 ], ( 0 : 2 * length (inds) - 3 ) + first (inds))
308+ return I[modrange (extend (lo, inds, hi), indices (I, 1 ) )]
308309 else
309310 error (" border style $(border. style) unrecognized" )
310311 end
0 commit comments