In [26]:
from tomokth.operators import io

In [5]:
%matplotlib inline

In [9]:
cd assignment/calibration_images/


/home/avmo/src/PIV/TomoKTH/examples/assignment/calibration_images

Reading images into array


In [3]:
arr = io.imread('0mm_cam0.tif')

In [4]:
print 'Image has been loaded as a 2d numpy array with ', arr.shape, 'rows and columns. Datatype =', arr.dtype


Image has been loaded as a 2d numpy array with  (500, 504) rows and columns. Datatype = uint16

Plotting images


In [10]:
io.implot('0mm_cam0.tif')



In [11]:
cd ../particle_images/


/home/avmo/src/PIV/TomoKTH/examples/assignment/particle_images

One can also use different matplotlib colormaps while plotting the images as demonstrated below.


In [12]:
io.implot('TomoImg_cam0_a00001.tif', cmap='jet')


Saving arrays as text files/images


In [25]:
io.imsave('raw_image_data.txt', arr)

The text file would contain many zeroes and few non-zero integers indicating the intensities at each pixel


In [27]:
import scipy as sp
sparse_arr = sp.sparse.coo_matrix(arr)
print sparse_arr


  (6, 406)	1
  (6, 407)	3
  (6, 408)	1
  (6, 458)	2
  (6, 459)	15
  (6, 460)	20
  (6, 461)	5
  (7, 301)	1
  (7, 302)	4
  (7, 303)	2
  (7, 353)	5
  (7, 354)	23
  (7, 355)	21
  (7, 356)	4
  (7, 405)	6
  (7, 406)	63
  (7, 407)	131
  (7, 408)	56
  (7, 409)	5
  (7, 457)	1
  (7, 458)	45
  (7, 459)	305
  (7, 460)	414
  (7, 461)	114
  (7, 462)	6
  :	:
  (493, 301)	1
  (493, 302)	4
  (493, 303)	2
  (493, 353)	5
  (493, 354)	23
  (493, 355)	21
  (493, 356)	4
  (493, 405)	6
  (493, 406)	63
  (493, 407)	131
  (493, 408)	56
  (493, 409)	5
  (493, 457)	1
  (493, 458)	45
  (493, 459)	305
  (493, 460)	414
  (493, 461)	114
  (493, 462)	6
  (494, 406)	1
  (494, 407)	3
  (494, 408)	1
  (494, 458)	2
  (494, 459)	15
  (494, 460)	20
  (494, 461)	5

In [ ]: