Image Partition into Blocks

A basic version:

using Images
using TestImages

img = testimage("cameraman")

"""
Partitions an image into an array of subimages
of pixel width w and pixel height h.
"""
function imblocks(img,
                  ( w,  h)::Tuple{Integer,Integer},
                  (dw, dh)::Tuple{Integer,Integer} = (0, 0))
    x = (size(img, 2) - dw) ÷ w
    y = (size(img, 1) - dh) ÷ h
    [view(img, (1:h) .+ (i*h+dh), (1:w) .+ (j*w+dw)) for i=0:y-1, j=0:x-1]
end
"""
Partitions an image into an array of sxs-pixel subimages.
"""
imblocks(img, s::Integer) = imblocks(img, (s, s))

imblocks(img, (128,64))

Padding left as an exercise.