This work proposes a novel idea, called SOIL, for reducing the computational complexity of the maximum a posteriori optimization problem using Markov random fields (MRFs). The local characteristics of MRFs are employed so that the searching in a virtually infinite label space is confined in a small finite space. Globally, the number of labels allowed is as many as the number of image sites while locally the optimal label is sampled from a space consisting of the labels assigned to the four-neighbor plus a random one. Neither the prior knowledge about the number of classes nor the estimation phase of the class number is required in this work. The proposed method is applied to the problem of texture segmentation and the result is compared with those obtained from conventional methods.