7 Oct 2019

Parameter optimization for auto-thresholding a data

In this pyscro example we use opencv and matplotlib to automatically calculate an optimized parameter for thresholding the data based on various metrics.

optimizer

In this pyscro example we use opencv and matplotlib to automatically calculate an optimized parameter for thresholding the data based on various metrics. This technique ensures an accurate and objective selection of the high intensity phase. Download the example, and load the hx file into Amira or Avizo. Then click the apply button of the optimizer module.


In some cases it is beneficial to optimize binarization parameters by using the image itself to compute the threshold level (maximum entropy or mutual information between greyscale and binary). The otsu method is a good example of this kind of auto-thresholding. The same methodology can be extrapolated to other binarization algorithms (i.e. top-hat, watershed, ...) or binary mask manipulation (erosion,opening, ...) associated with an image transformation (i.e. an image in which the separation power will be calculated). The general principle of such a tool has been easily prototyped in a pyscro script.


The thresholding is done based on OpenCV. Matplotlib allows to visualize the metric value based on the current threshold used. The automated optimized parameter is at the maximum of the curve.