Split image to several rectangles main implementation .