BF (bilateral filtering) has been widely considered to be a simple and effective way for extracting HSI (hyperspectral image) features. The algorithm limits the influence of non-structural similar pixels on target pixel by weighting spatial proximity and pixels similarity. However, non-structral similar pixels with a close spatial distance will be assigned larger weights, thereby reducing the effect of weighted limit. Therefore, this paper proposed a COBF (classified optimization BF), it selects the pixels with the most similar category structure from neighbor pixel sets to form a new template, ensuring the neighbor pixels in the new template that applied to the weight distribution as similar as possible in order to improve the features extract result. The COBF algorithm has been successfully applied to the feature extraction of several real HSIs. In order to verify the effectiveness of the proposed algorithm, SVM (support vector machine) was used to classify the HSI features that were extracted by COBF. The experimental results show that the overall accuracy is high when the number of training samples is only 10. The overall accuracies of Indian Pines, Salinas and PaviaU are 83.8%, 96.0% and 90.6%, respectively.