Little tricks collection

Load 16bit tiff images in python

Many high resolution scitific images are stored in the format of 16 bit tiff. The most famous python package in handling images are Pillow. However, pillow only support 8bit tiff images. I have explored two solutions that can load 16bit tiff in python. One is openCV and one is scikit-image.


The following commands will give us a 2D numpy array.

im =, plugin='tifffile')

The skimage is short for scikit-image. It can be installed in conda envirenment by

conda install scikit-image


The following commands will give us a 2D numpy array.

import cv2
im = cv2.imread(filename)

As openCV is not well-maintained in conda envirenment of python 3.6, I personally recommend using scikit-image. OpenCV will become the option only when some rare situation that scikit-image doesn’t work.

Interactive data visualization in Jupyternotebook

Data visualization in Jupyter Notebook lacks support for interactive feature. Recently, a python library named solves the problem.

A introduction of is avaliable here

Edit Complex Matlab Figures in Illustrator

If a figure is too complex, MATLAB will generate an embedded version of the origin image even when we export them as svg or eps. The embedded version is just like bmp image and lose the rich editable feature of vector image. Here, I’ll describe some simple steps that can export the editable vector version of MATLAB figures into Illustrator.

In figure window, choose the export setup. Export1

In export setup window,go to rendering and check “Custom renderer” as shown in image below. Export2

After doing this, either copying or exporting figure to svg/eps will generate fully editable vector image.

Written on June 29, 2018