In neuroscience, there is a model of the primary visual cortex of mammals V1 as a subriemannian structure over the group SE(2) of motions of the plane. The Hypoelliptic diffusion associated with this metric is used for the purpose of image completion or image reconstruction. In my talk, I shall present the theory, together with a semi-discrete improvement of the model more in accordance with the discrete structure of V1, over the group SE(2,N) of dicrete rotations and all translations. The group under consideration being maximally almost periodic, and therefore subject to Chu duality, there is a much simpler harmonic analysis on it. It results in nice and efficient algorithms both for image completion and pattern recognition.