We present an algorithm for processing of X-ray microtomographic (micro-CT) images that allows automatic selection of a sub-volume having the best visual quality for further mathematical simulation, for example, flow simulation. Frequently, an investigated sample occupies only a part of a volumetric image or the sample can be into a holder; a part of the image can be cropped. For each 2D slice across the Z-axis of an image, the proposed method locates a region corresponding to the sample. We explored applications of several existing blind quality measures for an estimation of the visual quality of a micro-CT image slice. Some of these metrics can be applied to ranking the image regions according to their quality. Our method searches for a cubic area located inside regions belonging to the sample and providing the maximal sum of the quality measures of slices crossing the cube across the Z-axis. The proposed technique was tested on synthetic and real micro-CT images of rocks.