extracting data from image

                I would like to be able to use the mouse to extract a 
rectangular area
from a displayed image, then either save the data in that area to a file
or perform calculations on the data.  Could you give me an idea of how i
might accomplish this.  thanks.