1. A method to process an image having a plurality of pixels, comprising capturing an image using an image sensor; forming a first-layer to encode local patches on an image region; and forming a second layer to jointly encode patches from the image region.