In order to recognize stored-grain insects by analyzing texture of the insects, a hidden Markov model (HMM) was developed to process the stored-grain insect images. First the basic theory of hidden Markov model was introduced, and then stored-grain insect image HMM was built. An improved K-mean method was used to initialize the HMM to improve algorithm efficiency and stability. Various stored-grain insect images were used to train the models using Baum-Welch algorithm. Use the trained HMM to recognize test images. The recognize accuracy rate for single insect with normal pattern is about 98%, for lateral position single insect is about 87%. The insects in the output images were counted by the method of connected component labeling, it was effectively solved the stored-grain insects' overlapping and adhesion, and the counting accuracy was improved.