1. A method for processing input low-resolution (LR) images to output high-resolution (HR) images, wherein the LR images and the HR images include corresponding LR-HR patch pairs, such that each patch includes pixel values, the method comprising: performing, by a processor, an offline training stage by: acquiring stored historical LR-HR patch pairs from a memory in communication with the processor, wherein each LR patch is a downsampled version of a corresponding HR patch of the same LR-HR patch pair; calculating a local n-ary pattern (LnP) for each LR-HR patch pair for all the LR-HR patch pairs, and grouping all LR-HR patch pairs with the same LnP value together; and obtaining for each LnP value a trained regression function appropriate for upscaling patches of that LnP value, and storing the trained regression function for that LnP value; performing, by the processor, a real-time upscaling stage of an input LR image by: acquiring each stored LR input image and processing each patch of the LR input image by: calculating a LnP value for each input LR patch, then using the LnP value to select a trained regression function for that patch, and then applying the selected trained regression function to that patch to obtain a corresponding HR patch; repeating the process for the remaining patches of the LR input image; and obtaining the HR output image from overlapping HR patches by averaging HR patch pixel values where HR patches overlap.