The number of medical images being stored and communicated daily is rapidly increasing, according to the need for these images in medical diagnoses. Hence, the storage space and bandwidths required to store and communicate these images are exponentially increasing, which has brought attention toward compressing these images. In this study, a new compression method is proposed for medical images based on convolutional neural networks. The proposed neural network consists of two main stages: a segmentation stage and an autoencoder. The segmentation stage is used to recognize the Region of Interest (ROI) in the image and provide it to the autoencoder stage, so more emphasis on the information of the ROI is applied. The autoencoder part of the neural network contains a bottleneck layer that has one-eighth of the dimensions of the input image. The values in this layer are used to represent the image, while the following layers are used to decompress the images, after training the neural network. The proposed method is evaluated using the CLEF MED 2009 dataset, where the evaluation results show that the method has significantly better performance, compared to the existing state-of-the-art methods, by providing more visually similar images using less data.