I am trying to reduce my cannon astro images by taking off the flatframe, which works. But it leaves all the values very low (so almost black picture), which is why I also want to multiply it with the average. However this gives me an error. (while without multiplication it works.)
Does anybody know why?
Traceback (most recent call last): File "D:\astro\10-12\moon\fits\red.py", line 16, in img = Image.fromarray(imarray) File "C:\Python27\lib\site-packages\PIL\Image.py", line 1886, in fromarray raise TypeError("Cannot handle this data type") TypeError: Cannot handle this data type
Here is my code
import Image
import numpy as np
im = Image.open('8bit/DPP_0001.TIF')
flat = Image.open('8bit/flat2.TIF')
#im.show()
imarray = np.array(im)
flatarray = np.array(flat)
avg = np.average(imarray)
imarray = (imarray/flatarray)*avg
img = Image.fromarray(imarray)
img.save("done/aap.png","png")
imarray.shapebefore and after the multiply, per stackoverflow.com/questions/7700193/… - lnmx>>> imarray = np.array(im) >>> imarray.shape (2848, 4272, 3) >>> avg = np.average(imarray) >>> imarray = (imarray/flatarray)*avg >>> imarray.shape (2848, 4272, 3)The shape did not change with me oddly - Coolcrabimarray.dtypebefore/after and tryimarray = numpy.uint8(imarray)beforefromarray. - lnmximarray = np.uint8((imarray/flatarray)*avg)Worked :D Post it and I'll upvote you :P - Coolcrab