0

I have a dataset and I want to delete all unreadable images. I tired to delete all unreadable images using python code given below, but interestingly I found that, when ran the code using opencv-3.0.0 it is able to read it. But when I tried to read same image using opencv-2.4.10 it returns 'None'. Here is the code I used:

Using opencv-3.0.0:

if cv2.imread(path_to_image) == None: os.remove(path_to_image)

Image is not removed

Using opencv-2.4.10:

if cv2.imread(path_to_image) == None: os.remove(path_to_image)

Image is removed

Here the one image that is unreadable. Can anyone say why is this happening?

mdilip
  • 1,126
  • 12
  • 14
  • There's currently an issue raised about the differences in reading in images between the two standards. Specifically, there are slight pixel differences between OpenCV 2.4 and OpenCV 3.0 - https://stackoverflow.com/questions/31607731/opencv-vs-matlab-different-values-on-pixels-with-imread and also http://code.opencv.org/issues/4148 - it comes down to the actual JPEG decoder itself and that it's different between versions... are your images JPEG? – rayryeng Aug 07 '15 at 14:19
  • Images in my dataset are JPEG only, but by doing `file image_name.jpg` it show file format as HTML, may be my dataset is corrupted too. Thanks for the references. – mdilip Aug 07 '15 at 17:59

0 Answers0