Get pixel data

I try get of the pixel information from a image, i need count number of pixel in a selection (mark),I don't found in api way to work in pixel level, please any suggestion is welcome

suggestion