Quite a few bytes saved thanks to rahnema1's idea (Octave answer) rahnema1's idea (Octave answer) of collapsing two convolutions into one
Quite a few bytes saved thanks to rahnema1's idea (Octave answer) of collapsing two convolutions into one
Quite a few bytes saved thanks to rahnema1's idea (Octave answer) of collapsing two convolutions into one
Quite a few bytes saved thanks to rahnnema'srahnema1's idea (Octave answer) of collapsing two convolutions into one
Quite a few bytes saved thanks to rahnnema's idea (Octave answer) of collapsing two convolutions into one
Quite a few bytes saved thanks to rahnema1's idea (Octave answer) of collapsing two convolutions into one
To detect vertical and horizontal neighbours, which contribute a distance of
1, the requiresrequired mask would be0 1 0 1 0 1 0 1 0
ToSimilarly, to detect diagonal neighbours, which contribute a distance of sqrt(2), the mask would be
If this mask is multiplied by sqrt(2) and added to the first, the two convolutions can be replaced by one convolution with the combined mask
To detect startStart and end points. These are, by definition, the points with only one neighbour. SeTo detect them we convolve with
1 1 1 1 0 1 1 1 1
To generateproduce the combined mask of item 1 it's shorter to producegenerate its square and then take the square root. MaskThe mask in item 2 is a predefined literal.
To detect vertical and horizontal neighbours, which contribute a distance of
1, the requires mask would be0 1 0 1 0 1 0 1 0
To detect diagonal neighbours, which contribute a distance of sqrt(2), the mask would be
If mask is multiplied by sqrt(2) and added to the first, the two convolutions can be replaced by one with the mask
To detect start and end points. These are by definition the points with only one neighbour. Se we convolve with
1 1 1 1 0 1 1 1 1
To generate mask 1 it's shorter to produce its square and then take the square root. Mask 2 is a predefined literal.
To detect vertical and horizontal neighbours, which contribute a distance of
1, the required mask would be0 1 0 1 0 1 0 1 0
Similarly, to detect diagonal neighbours, which contribute a distance of sqrt(2), the mask would be
If this mask is multiplied by sqrt(2) and added to the first, the two convolutions can be replaced by one convolution with the combined mask
Start and end points are, by definition, the points with only one neighbour. To detect them we convolve with
1 1 1 1 0 1 1 1 1
To produce the combined mask of item 1 it's shorter to generate its square and then take the square root. The mask in item 2 is a predefined literal.