Recently I bought a ASI224MC and have been testing it. When I ordered the camera, it was expected that you can save 12-bits raw bayer data of the IMX224 image sensor. But now I think you can't make it with the ASI224MC camera module and the softwares(sharpcap, firecapture) .
The followings are some python scripts for taking numpy array of the pixel data. They use three different ways to take pixel data(light intensity) from an image file. With these ways you can make a matrix representing image data of all pixels and also display it again.
(1) using libtiff library (installation: sudo pip install libtiff)
you should replace the file name with it of your .tif image file.
from libtiff import TIFF
import numpy as np
tiff = TIFF.open('Mars_001522_0007.tif', mode='rb')
array = tiff.read_image()
tiff.close()
print array
(2) tifffile.py (you should download copy it in your site-packages directory)
link: http://www.lfd.uci.edu/~gohlke/code/tifffile.py.html
import tifffile
import numpy as np
from matplotlib import pyplot as plt
tif = tifffile.TIFFfile('Mars_001522_0007.tif')
array = tif.asarray()
print array
(3) pyplot
from matplotlib import pyplot as plt
import numpy as np
array = plt.imread('Mars_001522_0007.tif','rb')
print array
All of them give you same numpy array. But the values are not 12 bit number!
You can check it with the following script.
from matplotlib import pyplot as plt
import numpy as np
def binaryarray(array):
= array.shape
array_bi = np.zeros((width,height), dtype=np.object_)
for i in range (0, width):
for j in range (0, height):
x = array
array_bi = np.binary_repr(x)
return array_bi
array = plt.imread('Mars_001522_0007.tif','rb')
print array
print "<binary form>"
print binaryarray(array)
print "display image"
plt.figure(figsize=(17,10))
plt.imshow(array, cmap = plt.get_cmap('gray'), interpolation='none')
plt.colorbar()
plt.show()
For my 'Mars_001522_0007.tif file, the result is like this.
What I heard from the ZWO is that the ASI224MC outputs 12bit raw data and you can save it in PNG or TIF format by using sharpcap or firecapture. So if you open it and read the pixel data, then you should see 16bit data for each pixels which have 12bit actual pixel data and 4bit zeros. For example, you would have '0101100000010000'. But it doesn't seem to be true, regarding the values in the numpy array. In my image file there exist a lot of pixels having values like 110100000101101. I doubt if the sharpcap and firecapture convert 12-bits raw data to 16-bits numbers, in other words, if the softwares do image processing when they save files.
Could anyone please confirm if it is true?
I tested PNG files too. They also consist of non zero 4 bits at the end of each pixel data.