-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbitplane.py
39 lines (32 loc) · 1.06 KB
/
bitplane.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
@author: Tanmoy Das Gupta, Sandeepan Sengupta, Tamojit Saha
"""
from configurator import configurator as cfgr
CHANNEL, PLANE, SCOPE, BUFFER = cfgr('setup.cfg')
def bitplane(image_file='image.tiff', DPI=1000, channel=CHANNEL, plane=PLANE):
"""
Usage:
bitplane('image.tiff', 1000)
bitplane('image.tiff', 500, 'R', 0)
"""
import os
from slicer import slicer as slc
import numpy as np
#from matplotlib.pyplot import imsave,imshow
import matplotlib.pyplot as plt
import matplotlib.cm as cm
base = os.path.basename(image_file)
bit_array = slc(image_file, channel, plane)
bit_array = np.reshape(bit_array, (-1,512))
#imshow(bit_array)
name = os.path.splitext(base)[0]
new_image_file = name+"_"+channel+"_"+str(plane)+".pdf"
plt.imshow(bit_array, cmap=cm.gray)
plt.savefig(new_image_file,format='pdf', dpi=DPI, bbox_inches='tight')
plt.clf()
plt.cla()
plt.close()
if __name__ == '__main__':
bitplane()