This paper presents a robust content-based image retrieval (CBIR) method utilizing texture analysis techniques, specifically through a combination of top-hat transform for shape detection and modified local binary patterns (LBP) for feature extraction. The method is evaluated on Corel and Simplicity image datasets, demonstrating superior precision and recall over existing approaches, while also maintaining low computational complexity and high reliability against noise and transformations. The proposed algorithm effectively detects and crops relevant image parts, enhancing the accuracy of image retrieval based on color, texture, and shape features.