Created
March 9, 2016 14:23
-
-
Save rukku/7fb23b4760a1cf1b92cd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from numpy import flipud | |
from numpy import zeros | |
import matplotlib.image | |
image_dn = zeros([494,659], dtype = float) #image size | |
filename = r'image_150529_123155_0x79_HPCM_750nm_659x494_complete.bin' #directory + filename ng bin | |
def binToInt(astring): | |
temp = ' '.join(format(ord(i),'b').zfill(8) for i in astring) | |
temp = temp[0:8]+temp[9:17] | |
temp = int(temp,2) | |
return temp | |
with open(filename, "rb") as f: | |
f.seek(89) | |
svt = f.read(2) | |
svt = float(binToInt(svt)) | |
sht = f.read(2) | |
sht = float(binToInt(sht)) | |
expT = (0.03337*svt)+(524-sht)*(0.00006356)+(487/780)*(0.00006356) | |
f.seek(95) | |
gain = f.read(2) | |
gain = binToInt(gain) | |
f.seek(651314) | |
wavelenght = f.read(2) | |
wavelenght = binToInt(wavelenght)+650 | |
f.seek(206) #start ng image data after header | |
for i in range(0,494): | |
for j in range(0,659): | |
data = f.read(2) | |
data = binToInt(data) | |
image_dn[i,j]=data | |
print "Wavelength = "+str(wavelenght)+"\n"+"Exposure time = "+str(expT)+" s"+"\n"+"Gain = "+str(gain) | |
image_dn = flipud(image_dn) | |
matplotlib.image.imsave("img_750.tif", image_dn, cmap="gray", format="tif") #bin to image file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment