This page is an example of how to obtain 2-point statistics using PyMKS tools. The workflow is the following: import image dataset, display the images, threshold the images if necessary, and calculate 2-point statistics for the images.
First, we will go through the process of calculating 2-point statistics on the full-size images at different magnifications and then perform the same procedure on cropped versions of the original images. Since sometimes images are very large, and we want to crop them to reduce the effort of computing the 2-point statistics.
The dataset that we are importing is optical micrographs of chemically etched low carbon steel. It is etched to display some features of the microstructure, which otherwise would not be visible.
In :import pymks %matplotlib inline %load_ext autoreload %autoreload 2
The autoreload extension is already loaded. To reload it, use: %reload_ext autoreload
In :from pymks_share import DataManager manager = DataManager ('pymks.me.gatech.edu') X = manager.fetch_data('Low-Carbon Steel Optical Micrographs')
Now, we will display the images using the PyMKS
In :import skimage.io as io import matplotlib.pylab as plt import numpy as np from pymks.tools import draw_microstructures draw_microstructures(X)
The images were taken at different magnifications (increasing left to right), 50x, 100x, 200x, 500x, and 500x with higher exposure value. Although the images were obtained using the same equipment, there are some variations in brightness, contrast, exposure, etc., to account for variation in image collection process.
The imported images are in grayscale. We need to make them black and white, since we know that there are only two different particles in the microstructure. We do this by thresholding the image using Otsu's method. By thresholding, each pixel in the image will become either black or white, giving us only 2 local states.
In :from skimage.filters import threshold_otsu X_thresh = np.array([threshold_otsu(x) for x in X]) X_binary = X > X_thresh[:, None, None]
In :draw_microstructures(X[2:4,:,:]) draw_microstructures(X_binary[2:4,:,:])