In today's world, especially in public places, strict security measures are being implemented. Among these measures, the most common is the inspection of the contents of people's belongings, such as purses, knapsacks, and suitcases, through X-ray imaging to detect prohibited items. However, this process is typically performed manually by security personnel. It is an exhausting task that demands continuous attention and concentration, making it prone to errors. Additionally, the detection and classification of overlapping and occluded objects can be challenging. Therefore, automating this process can be highly beneficial for reducing errors and improving the overall efficiency. In this study, a framework consisting of three fundamental phases for the classification of prohibited objects was proposed. In the first phase, a deep neural network was trained using X-ray images to extract features. In the subsequent phase, features that best represent the object were selected. Feature selection helps eliminate redundant features, leading to the efficient use of memory, reduced computational costs, and improved classification accuracy owing to a decrease in the number of features. In the final phase, classification was performed using the selected features. In the first stage, a convolutional neural network model was utilized for feature extraction. In the second stage, the Sparrow Search Algorithm was binarized and proposed as the binISSA for feature selection. Feature selection was implemented using the proposed binISSA. In the final stage, classification was performed using the K-Nearest Neighbors (KNN) and Support Vector Machine (SVM) algorithms. The performances of the convolutional neural network and the proposed framework were compared. In addition, the performance of the proposed framework was compared with that of other state-of-the-art metaheuristic algorithms. The proposed method increased the classification accuracy of the network from 0.9702 to 0.9763 using both the KNN and SVM (linear kernel) classifiers. The total number of features extracted using the deep neural network was 512. With the application of the proposed binISSA, average number of features were reduced to 25.33 using the KNN classifier and 32.70 using the SVM classifier. The results indicate a notable reduction in the extracted features from the convolutional neural network and an improvement in the classification accuracy.