[Elphel-support] Elphel Development Blog: Two Dimensional Phase Correlation as Neural Network Input for 3D Imaging

2018-07-20 Thread Elphel Development Blog
<<< text/html; charset=UTF-8: Unrecognized >>>
___
Support-list mailing list
Support-list@support.elphel.com
http://support.elphel.com/mailman/listinfo/support-list_support.elphel.com


[Elphel-support] Elphel Development Blog: Reading quad stereo TIFF image stacks in Python and formatting data for TensorFlow

2018-07-20 Thread Elphel Development Blog
Title: @@weblog










Elphel Development Blog


July 20, 2018 2:10 PM


You have subscribed to these e-mail notices about new posts to the blog.
If you want to change your settings or unsubscribe please visit:
https://blog.elphel.com/post_notification_header/?code=cd9ad4791210eef4735d43f52cc21dd2=support-list%40support.elphel.com&

Reading quad stereo TIFF image stacks in Python and formatting data for TensorFlow
Fig.1 TIFF image stack
The input is a .tiff – a TIFF image stack generated by ImageJ Java plugin (using bioformats) with Elphel-specific information in ImageJ written TIFF tags.
Reading and formatting image data for the Tensorflow can be split into the following subtasks:

convert a TIFF image stack into a NumPy array
extract information from the TIFF header tags
reshape/perform a few array manipulations based on the information from the tags.

To do this we have created a few Python scripts (see python3-imagej-tiff: imagej_tiff.py) that use Pillow, Numpy, Matplotlib, etc..
Usage:
~$ python3 imagej_tiff.py .tiff
It will print header info in the terminal and display the layers (and decoded values) using Matplotlib.

Details
Subtasks 1. and 2. are simply done by Pillow. As for 3., if it was a simple TIFF image stack there would be no need to have extra scripts. 
If the layer were just stacked along depth the shape would be (2178, 2916, 5). The script reshapes the data into tiles and puts the values into a separate array, so the output is 2 Numpy arrays:

image data shape:  (242, 324, 9, 9, 4) with the layers along the last dimension
values data shape: (242, 324, 3)

And they are ready to be used in the Tensorflow.
For more details and example output, see this wiki page or inspect the source. The most detailed general info is probably in the slides from our presentation for CVPR2018 – format description starts from p.19.
File samples
Actual files can be found here or go to 3d+biquad, open individual models and hit the light green button to ‘Download source files for ml’.
Without using Python displaying layers and decoding tags is natively supported by ImageJ or Fiji. To read the tags exiftool or tiffinfo linux programs can be used.
Other libraries
Other Python libraries that could have worked (but examples for Pillow were easier to find):

tifffile
imageio
opencv
python-bioformats








___
Support-list mailing list
Support-list@support.elphel.com
http://support.elphel.com/mailman/listinfo/support-list_support.elphel.com