1. An image processing apparatus comprising: an input arranged to receive at least one patch of an image; a memory storing a data structure holding at least one masked restricted Boltzmann machine comprising a plurality K of restricted Boltzmann machines each arranged to receive input from the patch of the image and having shared parameters and also comprising a mask having a variable for each image element of the patch specifying which of the plurality of restricted Boltzmann machines is to be used for that image element; a processor arranged to input the patch to the masked restricted Boltzmann machine and obtain hidden node activations of the plurality of restricted Boltzmann machines; an output arranged to provide a plurality of superpixel elements being latent features of the patch and comprising the hidden node activations of the plurality of restricted Boltzmann machines.