Practical Work: Steel microstructure#

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

../../_images/HSLA_340.jpg

The microstructure of an HSLA340 cold rolled steel is available here (or just right-click and download). Download it and put it into your current work directory.

%matplotlib widget
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 os
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 ['HSLA_340.jpg', '.ipynb_checkpoints', 'dices.jpg', 'coins.jpg', 'image_processing_practical_work_bonus.ipynb', 'image_processing_practical_work.ipynb', 'image_processing_tutorial.ipynb', 'exercises.md']
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 HERE

Thresholding#

Use thresholding to convert the image to binary format.

# CODDE HERE

Labeling#

Use the ndimage.measurements.label to label each grain and plot the result.

# CODDE HERE

Grain 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 HERE

Grain 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