In this tutorial, you will study the microstructure of an HSLA steel.

Introduction¶
This image is a micrograph of a high-strength low-alloy (HSLA) steel. The image was taken using a scanning electron microscope (SEM) and shows the microstructure of the steel. The microstructure shows grains and separated by grain boundaries. The grains are regions of the material where the atoms are arranged in a regular pattern. The grain boundaries are the interfaces between the grains. The size of the grains and the distribution of the grain boundaries are important for the mechanical properties of the material. For example, the Hall-Petch equation relates the yield strength of a material to the average grain size.
Ressources¶
Objectives¶
In this tutorial, we will measure the grain size as well as the grain shape factor and the grain orientation.
Tasks¶
# IF USING JUPYTER LAB, USE THE FOLLOWING COMMAND:
%matplotlib widget
# IF USING JUPYTER NOTEBOOK, USE THE FOLLOWING COMMAND:
# %matplotlib notebook
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
from scipy import ndimage
import pandas as pd
import osMatplotlib is building the font cache; this may take a moment.
name = "HSLA_340.jpg"
workdir = "./"
files = os.listdir(workdir)
if name in files:
print("Ok, the file is in {0}".format(files))
else:
print("The file is not in {0} , retry !".format(files))Ok, the file is in ['dice.jpg', 'coins.jpg', 'HSLA_340.jpg', 'exercises.md', 'image_processing_practical_work.ipynb', 'image_processing_tutorial.ipynb', 'image_processing_practical_work_bonus.ipynb']
im = np.array(Image.open(workdir + name))
fig, ax = plt.subplots()
ax.axis("off")
plt.imshow(im, cmap=cm.copper)
plt.colorbar()
plt.show()Histogram¶
Plot the histogram of the image and find the right level for the thresholding.
# CODDE HEREThresholding¶
Use thresholding to convert the image to binary format.
# CODDE HERELabeling¶
Use the ndimage.label to label each grain and plot the result.
# CODDE HEREGrain size measurement¶
Use the labeled image to measure the size (in pixels) of each grain. Create a new image on which the color of each pixel indicates the size of the grain it belongs to.
# CODDE HEREGrain shape factor and orientation¶
The cold rolling treatment modifies the shape factor as well as their orientation. Find a way to measure and represent the shape factor of each grain and to mesure their orientation.
# CODDE HERE