Tips for creating a texel density visualization mode

I’m trying to add a visualization mode that highlights pixels with a texel : pixel ratio of less than one. Has anyone made something like this before, or have any advice on how to achieve this?