Douglas, you need to use impixelinfo(), not hpimpixelinfo(). And you probably need to adjust where it is so you can see it. And you're passing in 2. I wouldn't do that. I'd just call it right after you call imshow() to make sure you're using it on the right figure.
hp = impixelinfo();
hp.Unit = 'normalized';
hp.Position = [0.01, 0.98, 0.2, 0.1];
If that doesn't show the pixel values in the upper left of your figure, then adjust the position.
Basically you can extract the color planes
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
and, if your red is exactly (255,0,0) then find those pixels like this
redPixels = redChannel == 255 & greenChannel == 0 & blueChannel == 0;
To find black (0,0,0) pixels:
blackPixels = redChannel == 0 & greenChannel == 0 & blueChannel == 0;
To find white (255,255,255) pixels:
whitePixels = redChannel == 255 & greenChannel == 255 & blueChannel == 255;
If your colors are not pure computer graphics like that, then see my File Exchange app, or see the Color Thresholder on the Apps tab of the tool ribbon.