A method for segmenting an image comprising: computing a first image signature for an input image; identifying at least one similar image from a first set of images, based on the first image signature and image signatures of images in the first set of images; generating a cropped region of the input image based on the identified at least one similar image; computing a second image signature for the cropped region; identifying at least one similar image from a second set of images, based on the second image signature and image signatures of images in the second set of images; and segmenting the input image based on a segmentation map of at least one of the at least one similar images identified in the second set of images; the method further comprising projecting the first image signature into a feature space with a first learned projection matrix and wherein the identifying of the at least one similar image from the first set of images comprises computing a similarity between the projected first image signature and projected image signatures of the images in the first set projected with the first learned projection matrix; and projecting the second image signature into a feature space with a second learned projection matrix and wherein the identifying of the at least one similar image from the second set of images comprises computing a similarity between the projected second image signature and projected image signatures of the images in the second set projected with the second learned projection matrix; wherein at least one of the first and second projection matrices is learned by defining the similarity of the projected image signatures of an image i and an image j as k A x i x j = x i T A T Ax j where A is the learned projection matrix, x i is the image signature of image i, and x j is the image signature of image j; and minimizing the loss function L A = ∑ ∀ i, j, k s. t. Ψ S i S j > Ψ S j S k max 0, k A x i x k + q − k A x i x j. for a set of training images by using an iterative process, where S i is the segmentation map of an image i, where Ψ( S i, S j) is the similarity of segmentation map S i and segmentation map S j and is given by Ψ S i S j = Area S i ∩ S i Area S i ∪ S j and where q is a positive constant. computing a first image signature for an input image; identifying at least one similar image from a first set of images, based on the first image signature and image signatures of images in the first set of images; generating a cropped region of the input image based on the identified at least one similar image; computing a second image signature for the cropped region; identifying at least one similar image from a second set of images, based on the second image signature and image signatures of images in the second set of images; and segmenting the input image based on a segmentation map of at least one of the at least one similar images identified in the second set of images; the method further comprising projecting the first image signature into a feature space with a first learned projection matrix and wherein the identifying of the at least one similar image from the first set of images comprises computing a similarity between the projected first image signature and projected image signatures of the images in the first set projected with the first learned projection matrix; and projecting the second image signature into a feature space with a second learned projection matrix and wherein the identifying of the at least one similar image from the second set of images comprises computing a similarity between the projected second image signature and projected image signatures of the images in the second set projected with the second learned projection matrix; wherein at least one of the first and second projection matrices is learned by defining the similarity of the projected image signatures of an image i and an image j as k A x i x j = x i T A T Ax j where A is the learned projection matrix, x i is the image signature of image i, and x j is the image signature of image j; and minimizing the loss function L A = ∑ ∀ i, j, k s. t. Ψ S i S j > Ψ S j S k max 0, k A x i x k + q − k A x i x j. for a set of training images by using an iterative process, where S i is the segmentation map of an image i, where Ψ( S i, S j) is the similarity of segmentation map S i and segmentation map S j and is given by Ψ S i S j = Area S i ∩ S i Area S i ∪ S j and where q is a positive constant.