Is there a way to detect the different sizes of 2 different selections with identical bounding rectangles?
Using app.activeDocument.selection.bounds will return the dimensions of a rectangle bounding the selection. The two selections below will return identical bounds (39px x 38px). How can I distinguish them programmatically?

When your selection images have been converted to black and white bitmaps:
So the trick is to take a colour sample of each pixel. We're not really interested in the colour of the pixel, but where it's part of the selection or not. Black if it is, white if it's not.
Then it's a matter of looping over the whole image, counting as you go. In a 39x38 size pixel image, the script will take a few seconds. On something larger, much much longer.