Phases in duplex steel

Dears,

I have some troubles with the thresholding of electrolytically etched duplex steel. As you can see in the picture below, one phase colours blue, the other something between white and yellow.

Because the lightest blue in the blue phase is as bright as hte darkest white in white phase thresholding is very difficult. If it would be possible to place a 1-pixel thick line between both phases, i could walk through all pixels starting and change the color until a black line is passed, then color white until the next black line is passed, …

Could anyone help me separating the phases of placing a 1- pixel thick, closed line between the phases.

THanks in advance!

Bas Werbrouck
Bekaert company

Hi @BasWerbrouck,

The following idea might work (and can be improved via pre-filtering or contrast and lighting adjustments).
Or you can give the Trainable Weka Segmentation a trial.

run("HSB Stack");
setSlice(2);
run("Median...", "radius=2 slice");
setOption("BlackBackground", true);
setAutoThreshold("Huang dark");
run("Convert to Mask", "method=Huang background=Dark calculate black");
run("Create Selection");
run("Revert");
run("Overlay Options...", "stroke=red width=2 fill=none set");
run("Add Selection...");
6 Likes

@Biovoxxel, thanks for you help!

I adjusted your code to my needs, the picture at the bottom of this post shows the separation, which is quite good. If anyone has a better shot, be welcome :slight_smile:

imageTitle=getTitle();
run("Duplicate...", "title=DIA");
run("Subtract Background...", "rolling=50 light");
run("HSB Stack");
setSlice(3);
run("Delete Slice");
setSlice(1);
run("Delete Slice");
run("Bilateral Filter", "spatial=3 range=50");
rename("DIA2");
selectWindow("DIA");
run("Close");
selectWindow("DIA2");
setOption("BlackBackground", false);
setAutoThreshold("Huang dark");
run("Convert to Mask", "method=Huang background=Dark calculate black");
run("Options...", "iterations=2 count=1 do=Open");
run("Red");
selectWindow(imageTitle);
run("Add Image...", "image=[DIA2] x=0 y=0 opacity=50 zero");
selectWindow("DIA2");
run("Set Measurements...", "area_fraction redirect=None decimal=2");
run("Select All");
run("Measure");
run("Close");

2 Likes

I played a little with trainable Weka Segmentation and got a similar result when selecting “variance” as the only training feature

1 Like