The woven fabric is a flexible object and to specify its parameters, applying inflexible and ordinary methods of image processing ever have considerable errors. In this regards, proposing an adaptable method to fabric image properties is concentrated to detect the yarns position. In this research, a flexible algorithm is proposed containing two stages: first, the inexact ranges of fabric parameters are determined by preprocessing colored fabric images using wavelet transform and clustering methods. Then, the hybrid genetic and imperialist competitive algorithm is applied to optimize the obtained ranges and detect the yarns position. To achieve better results, the parameters of the hybrid ICA-GA are calibrated using the Taguchi method. Results indicate that in this new method, the error value of detecting structural fabric parameters has considerably decreased to 5% as compared with common gray-scale projection method. The proposed method is capable of detecting the exact yarns position in colored fabric images with uneven color intensity and low-density weave with mean precision value of 96.2%. In the fabric images with high density weaves, the mean precision value is more than 94.72%.