This paper proposes a novel method of texture analysis based on the mathematical morphology. The pattern spectrum is a mathematical morphological method to describe size distributions of objects contained in an image. Our method is based on the idea to optimize the shape of structuring elements to fit the shape of elementary particles that form a texture. Since the variance of size distribution described by the pattern spectrum is small if the structuring element for calculating the pattern spectrum fits the particles, the shape of elementary object is obtained by the structuring element optimized to reduce the variance of size distribution. Experimental results are shown when the structuring element is restricted to binary ones of 5x5-pixels.