How to create a box on a image and capture all pixel position inside the box

Hi,

I upload an image, image is display on the page. then I create a box (red box) with mouse click. After released, i plan to capture all pixel coordinate inside the box.

How could i achieve this. Is it possible in Vaadin or I need to use javascript and create a custome function?

thank you.

regards
sLawalata