Finding grain orientation in the weilding heat-affected zone with the hough transform
The microstructure of an austenitic weld originates in the dentritic type growth along the axis of the heat flow direction. In some cases, this leads to elongated and oriented grains which can grow with epitaxic process on several millimeters length. An example of metallographic observations on a transversal section of an austenitic weld clearly reveals the columnar grain structure (Figure). It reveals an heterogeneous structure due to the weld geometry: on each side of the weld, the grains are perpendicular to the chamfer and they are slightly tilted with respect to the vertical in the middle of the weld.
Several applications like, for example, Finite Element simulations, requires to determine the local orientation inside the weld.
The Hough transform
The Hough transform is a wonderful trick. With a voting system, it tells where there are things looking like a straight line. It tells it in a graph with orientation in abscissa and distance from the “origin” in ordinate. All this is much clearer once you have tested an image with the G’mic command x_hough:
gmic image.jpg -x_hough
The Hough transform the way I like it
The idea here is to cut the HAZ image in small square samples and to estimate the main orientation of each sample thanks to a hough transform. Since the distance from the origin is of no interest, the hough transform is asked to be one pixel high. The abscissa of the maximum value gives the main orientation.
If the principle is applied to the ladybug picture seen above:
gmic ladybug.jpg -hough 360,1 -display_graph
Two peaks can be seen, one at about 115° and one at about 295° (180° more, which means the same orientation). They both correspond to the herb orientation.
The Custom command
With the 1D hough transform, some treatment is applied to get only one peak. The maximum position gives the main orientation and it is even possible to build a confidence criteria based on the maximum value.
The custom command proposed here takes 2 parameters, one for the sample size and one for the accuracy. Setting a low accuracy is a way to cope with the high frequency oscillation seen on the curve, there are probably better ways to handle that.
At the end the G’mic command below shows a quite acceptable result in less than one second :
gmic macro.gmic haz.png --haz_orientation 40,10 -compose_rgba[0,1] -keep
Edit : from the version 184.108.40.206 on, image blending has been rethought, thus the command line above becomes:
gmic macro.gmic haz.png --haz_orientation 40,10 -blend[0,1] alpha -keep
Of course, it can be much improved. As already said, the custom command can be refined to be more accurate by applying for example some gaussian blur on the 1D hough transform. “Some people” will want to get an orientation estimation at each pixel, this should be easy to make. And it would be great to get that estimation only based on information inside the HAZ, this will require some thinking and probably some semi-manual HAZ contouring. It will also quickly become important to be able to handle pictures with small defects inside because HAZ photography can not always be that clean. For that, I plan to make some inpainting in zones whose values are too different from their neighborhood, but I face an awkward issue : how to make G’mic understand that 0° and 179° are not distant numbers?