Patch-based image analysis: application to segmentation and disease classification