Flag the invalid samples of a row-major grid that are connected (4-neighbour)
to the grid border, returning a mask where 1 marks a border-connected
("external") invalid sample. Invalid samples fully enclosed by valid data
(internal holes) are left as 0, so the caller can distinguish the outer rim
of a footprint from holes punched inside it (e.g. to fill the latter while
keeping the former as the true outline).
Flag the invalid samples of a row-major grid that are connected (4-neighbour) to the grid border, returning a mask where
1marks a border-connected ("external") invalid sample. Invalid samples fully enclosed by valid data (internal holes) are left as0, so the caller can distinguish the outer rim of a footprint from holes punched inside it (e.g. to fill the latter while keeping the former as the true outline).