Im trying to do a small project on machine learning and in the process of doing so I have to convert a few images into black and white to classify the images. My problem is that the same method produces wildly different results with the same algorithm. Here is the image before it is converted Image 1 and this is what it looks like after its been converted. Yeah that works fine looks okay.
This is the code that I used.
test_img=Image.open(str(idx) + '.png')
test_img=test_img.resize((100,100),Image.ANTIALIAS)
test_img.show()
test_img=test_img.convert('1')
Now I will ty to do the same with this image which produces this result. As you can see aster it is converted I have weird black spots all over the image. This is the code that I used:
source_img=source_img.resize((100,100),Image.ANTIALIAS)
source_img=source_img.convert('1')
source_img.show()
Ive tried multiple methods to convert an image to black and white including the source_img.convert('L')
method and with other methods I'm not able to flatten the image out into a 1D array.
Does anyone know why the conversion works for the first image but not the second?