Hi all,
I am trying to create a binary mask for a single raster band in such a way that >75% of the pixels in each 3x3 block of the raster are regarded as valid pixels (1) and 25% or less are regarded as invalid (0).

Much like the above throughout the raster. My thought was to create a numpy mask array and then multiply that by an array of the raster itself but I'm not sure how to create a masked array with such specific details.
Any help would be greatly appreciated.