Thursday, May 14, 2015

Imagej tutorial for determination of phase percentage

Phase percentage can be easily calculated in a micrography, with the aid of the image analysis program ImageJ. It can be downloaded from http://imagej.nih.gov/ij/download.html.

It is an image analysis program developed for use in the medical area, that has great potential for the metalographic laboratory.
The program may seem not user friendly, but after some time its great potential becomes evident.
The following tutorial is aimed to help newbies, showing its operation step by step.
Analysis will be carried out in a micrography of duplex (austenitic-ferritic) stainless steel. The image credits go for my friend Guilherme Araújo.

1. Opening the image

When Imagej is open, it displays the window shown below. Images and dialog boxes are open in independente windows.

To open the image, which is in jpg format:
File > Open
Slelct the image you want to open, then clic Open, in the dialog box.


Then, the image will be displayed. In this case, the brown phase is ferritic, while the bright one is austenitic.


2. Image preparation

 In order to make easier the next steps, the image must be converted to grayscale:
Image > Type > 8-bit.
 
Next step is thresholding. The 8-bit image has 256 shades of gray. Thresholding turns the image in black and white (whitout intermediate gray shades). This is the most important step of the analysis, because it selects which pixels are going to be used in the calculation and which will be out of the role.
Imagej has algoritms to automatically adjust the threshold, but it is possible to make it manually. The automatic method will be used.
Image > Adjust > Theshold...
in the dialog box, leave Dark background flagged. In the case of  analysis of the opposite phase, this box should be unflagged. We will accept the automatic threshold:
Click the "Auto" button > click "Apply" buton > close the dialog box clicking on "X".
 

3. Analysis preparation

Now, we will inform to the program which are the analysis that we want to perform.
Image > Set Measurements...

In the dialog box, leave just "Area" and "Area fraction" flagged.


4. Measurements

Finally, the analysis can be performed.
Analyze > Measure

And then, we have the area percentage of the dark phase: 46,026% of the pixels (and, therefore, of the area of the micrography). It represents 1920000 pixels in this image.


5. Saving the thresholded image

You may want to save the thresholded image for further use. Don't forget to give a different name for the new image, otherwise the original may be overwritten.
ImageJ can work with several windows open. The program philosophy is to apply the commands only for the selected window. Therefore, in order to avoid errors, the window in which we are working must be always selected. To do this, you may click on the title bar of the image.

Once the image is selected, just save it in your preferred format. In this example, we will save in jpg format.
File > Save As > Jpeg

6. Conclusion

The procedure described above, basically, may be used in the measurement of any type of phase, and can be easily used to measure pearlite fraction in carbon steel, for example.
A good metallographic preparation has fundamental importance. With the due preparation and correct etching, virtually any type of phase may be calculated. In a more sophisticated application, sigma phase can be measured in austenitic stainless steel. In this case, it would be necessary to use a color image (instead of an 8-bit grayscale), and to use color thresholding, after KOH electrolytic etching.
This is just a very simple example of Imagej use in image analysis. The program is very powerfull, and can be used for several activities. It may put the famous scalebar but also can make more complex measurements, like grain size automatic measurement. It can also help in image acquisition, dealing with image stacking to correct insufficient depth of field in the microscope, sometimes caused by lack of planicity in metallographic sample.

7. I'm so sorry...

...for my macaronic english. I'm trying to improve, and this blog is part of the game. Even so, I hope it may help you.