A method for producing a graph representation of an input image, the method including the procedures of applying convolutional layers of a trained convolutional neural network on the input image, defining a receptive field of a last convolutional layer of the trained convolutional neural network as a vertex of the graph representation, defining a vector of a three dimensional output matrix of the last convolutional layer that is mapped to the receptive field as a descriptor for the vertex and determining an edge between a pair of vertices of the graph representation by applying an operator on a pair of descriptors respective of the pair of vertices.