DOC: Find the indices and number of pixels for rectangle shapes

open this branch due to conflicts in the previous branch( merge conflicts markers)
Added an ROI which goes out of bounds, and simplified the loop