Roi

Implemented ROI functions (large pull request).