Segmentation: Help with Interpolating Edges

Hello guys,

I am working on carbonate crystal structures in bivalve shells and have alot of SEM images of polished and etched thick sections. I am trying to measure crystal sizes and shapes and for that reason am trying to segment individual crystals.

My typical image looks like this:

I am working alot on improving image quality / preparating technique to segment the crystals via etching before taking the pictures. Nontheless, I need to produce first data with what I have and am looking for a routine to get the best result.

With Trainable Weka Segmentation or also with Automatic thresholding I can achieve a reasonable result like this:

The crystals are seperated quite well, however there are a lot of artificial “bridges” where the contrast wasn’t high enough to segment individual crystals. I’ve circled some of them in this picture:

So my Question is how can I “interpolate” the lost elements of segmentation? I understand that watershed is suited quite well for this. However I still fail to apply it as it heavily over-segments other areas of the picture. Is what I am trying to achieve not possible? Will I need to put more effort in sample preparation / image acquisition for this to work at all? Is my segmentation method faulty?

Good day!

You tried quite some methods yet but I don’t think you will get significantly better results, given the image quality. The images are rather noisy and the spatial resolution is quite low. If you use a proper automatic threshold scheme, you should first exclude the descriptive bar at the bottom, because it influences the image histogram and , as a consequence, the threshold.

Did you try to reduce the noise by low-pass filtering?
I’d start with Median-filters.

In Fiji you have local automatic threshold schemes.
Did you try?

Will I need to put more effort in sample preparation / image acquisition for this to work at all?

Yes!

Is my segmentation method faulty?

No.

Regards

Herbie

1 Like

The images are rather noisy and the spatial resolution is quite low

I know that the acquisition is the main point here. I am having several troubles with it but try my best to improve it. If I improve the resolution by choosing longer exposure times, but then the sample drifts and the image gets blurry. I can influence the amount of etching (bigger or smaller gaps between crystals), which is a lot of experimenting and I am getting closer to optimal. The noisiness is already getting better thanks to a new kathode and better sputtering of the SEM samples.

Did you try to reduce the noise by low-pass filtering?
I’d start with Median-filters.

FIJI’s “despeckle” already does a good job reducing noise in the images, but I’ll try further mehods.

If you use a proper automatic threshold scheme, you should first exclude the descriptive bar at the bottom

Thanks for the tip, didn’t think of that, but it’s so obvious

In Fiji you have local automatic threshold schemes.
Did you try?

I just tried and it improves the segmentation quality. I chose 102 pixels (1/10 of the entire image).

However, all the improvements don’t resolve the original issue: Some crystals are still connected and not entirely separated. Is there a way to manipulate watershed, so that it doesn’t over-segment parts of my image but only fills in the necessary brigdes?

If I choose a thesholding method that seperates each crystal very well, I have over-segmentation in many areas. Another idea would be to combine two methods that are “too strong” and “not strong enough” to combine them in a perfectly segmented result. But I am struggling to implement this.

If I improve the resolution by choosing longer exposure times

I wrote

the spatial resolution is quite low

and it can’t be imrpoved by high exposures!

Another idea would be to combine two methods […]

Don’t bother with image processing.
Invest all your efforts in better sample preparation and image acquisition!

Look for specialized Forums that deal with SEM etc.

Good luck

Herbie

In SEM longer exposure times also create a higher resolution image.

Invest all your efforts in better sample preparation and image acquisition!
Look for specialized Forums that deal with SEM etc.

As I wrote, I am doing this already. There are some limitations however, and, as I also wrote, I need to start producing results with what I have.

I appreciate your help but please only comment if you have constructive suggestions regarding my main question. “Don’t bother with image processing” is not an option for me.

In SEM longer exposure times also create a higher resolution image.

So you get more pixels?

As I wrote, I am doing this already.

I know, but you have asked again!

[…] but please only comment if you have constructive suggestions regarding my main question.

Thanks for your kind words.

“Don’t bother with image processing” is not an option for me.

This was meant as a serious constructive comment.
The posted sample image is simply not suited for the result you are expecting, no matter what kind of image processing you apply. If WEKA-classification doesn’t work, then there is little hope for a reasonable result.

I accept that this is no option for you and I’m curious to see where you are going to invest any further efforts. Please keep us informed if you’ve reached a reasonable result from the posted sample image.

Regards

Herbie

Here is an example of touching binary objects:

Here is what you get from using “Process >> Binary >> Warershed”:


I know you’ve been there: Over-segmentation

What you get with some a priori knowledge about what touching means in cases in question and with quite some non-trivial processing is:

If you suspect the separating line being hand-drawn, you are wrong. It is drawn according to a mathematical analysis that however doesn’t generalize to all of the separation problems you are confronted with in your binarized image.

Regards

Herbie

Hello Cripcate,
I would like to give you a little tip. I don’t know how much experience you have with SEMicroscopy, Calcium Carbonate or Fractals but what you see in your images is a natural Fractal pattern. Grown in millions to billions of layers from a centralized point. That’s what gives the shell its shape, and if you look at the cleaned, smooth inner shell you will notice the various colors seen when in sunlight. It acts like a diffraction grating.
It doesn’t matter how you prepare it the pattern will keep showing up. So you have to pick the size range of patterns you are interested in, for instance you could use the whole shell and catagorize it as one crystal with the dimentions of the shell, or choosing a perimator of 100 px^2 to infinity
Slice Count Total Area Average Size %Area Mean Perim.
From cripcateA.png 258 32405 125.601 2.909 255 124.232

or even a periamator of 0 to 100 px^2:
Slice Count Total Area Average Size %Area Mean Perim.
From cripcateA.png 20511 278693 13.587 25.015 255 18.218

Just a little hint as to what you’re up against.
Bob

Hey smithrobertj,

I don’t totally get what you’re saying, but kind of think i know what you mean. To clarify / give more background info: This is a bivalve shell of A. islandica. I am interested in size and shape of individual “Biomineral-Units”. Bivalves are active calcifiers and don’t just form “normal” calcite crystals as would be precipitated anorganically. They actively influence the shape of the crystals in their shell. This picture is from the outer shell layer. There are many different microstructure types like crossed-lamellar, complex-acicular etc. This one is the homogenous microstructure which I am starting out with.

I know that it’s not the easiest material to analyse, but it’s a product of nature and I can’t influence it enough to be easily processed by a computer. It’s a hard task but I’ll get around it.

So you have to pick the size range of patterns you are interested in

What for? Do you mean for the tolerance level of Watershed? Or for the auto local threshold?

Yes, i can choose between a 1024 pixel width (3s exposure) or 2048 pixels (13s exposure). I’m trying to use the higher one, but sometimes the sample moves too much during exposure leading to a blurry image.

Yes, i can choose between a 1024 pixel width (3s exposure) or 2048 pixels (13s exposure). I’m trying to use the higher one, but sometimes the sample moves too much during exposure leading to a blurry image.

How do images look like with say 5 sec exposure and 2048 pixel side length?

Did you try?

Herbie

Hello again,

Biomineral-units will change in various ways such as size, numbers and shape dependant upon their environment as you know, yet there also pattern guideance which are more easily discerned by fractal pattern analysis. Very much like the pattern to limb structure in trees.

First try to determine a fractal pattern which you can do with the help of Plugins > Fractal Surface measurement (you can obtain this plug-in on the plug-in website maintained by ImageJ/Fiji).

By “size” I was referring to the size and area, shape of the particular resolution you are using. As can be seen that the higher the resolution, the higher the number but smaller in area you will be able to visualize.

Your topic is very interesting and I would recommend becoming a little more familiar with Fractals (Wikipedia) then you will better understand what you are seeing (easy stuff ). Also Iowa State University has a very good article on Biomineral Units also found in Wikipedia.

It won’t add any time to your analysis and will aid you in the long run.

Hope this helps and Good Luck,
Bob

As a small example, the following derived from your first image as is.
Hope it helps,
Bob (again)

Plot%20of%20Fractal%20Results

Fractal Plot Values.csv (307 Bytes)

Fractal Plot

Could someone please enlighten me what this has to do or how it can help with the problem of segmenting the image in question?

Clueless

Herbie

I see what you are pointing at @smithrobertj and am reading into fractal analysis. I never dealt with fractals before but it sounds promisind. however I am still unsure if fractal analysis applies to my situation.

Ultimately I want to track changes in crystal size and shape (elongation, circularity, etc.) over the course of the shell, to relate them to environmental parameters like sea-temperature (it influences biomineralization of the bivalve). A starting point would be this paper: https://www.sciencedirect.com/science/article/pii/S0031018215005611

The image I uploaded (homogenous microstructure) might resemble a fractal. However, I need to apply this to a range of other microstructures that look very different. Take these for instance:


I don’t think fractal analysis could apply to all of them. And maybe I should stick to “conventional” methods (segmentation and particle analysis). There are so many parameters, that it’s very hard to determine the best analysis routine. First, it matters what species, shell-layer and microstructure are present. Second, it matters how well I polish my specimen, what acid I use for etching, in what concentration and for how long I submerge. Then also the sputtering material and thickness in the SEM, the voltage, brightness, contrast, magnification, focus, image resolution etc. etc. etc.

Sometimes it’s overwhelming :smiley:

I’ll notify you guys if I make significant progress. Right now the best method seems to be thresholding coupled with erosion. This way my crystal sizes are a little too small, but that doesn’t really matter as long as theyre well segmented and uniformally too small.

If you have any further tips feel free to pitch me :slight_smile:

Would you please show us how

thresholding coupled with erosion

solves your initial problem?

Please post a result image.

Regards

Herbie

Hi,

concerning the noise:
You could take several images, align them (e.g. StackReg plugin) and then average them, to reduce the noise.
But it is not only noise, much of what looks like noise is electromagnetic interference; you can clearly see this as vertical lines if you take a Fourier transform of your image.
Assuming your sample image was taken with 3 sec exposure, the strongest noise frequencies are about 50 kHz, which is typical for switching-mode power supplies as used in computers.
A person with good knowledge in electronics might find a way out. My first idea would be trying ferrite chokes (Snap-together ferrite choke cores) around the cable of the BSD detector (if you can access it), around the cable from the control computer to the SEM, around the power cable of the control computer, etc.

Concerning the segmentation, is there no plugin around for enhancing lines? I think of something like correlation with short line segments of all different directions, and enhancing the lines where the correlation is particularly strong.

– Michael

1 Like

Thanks Michael for pointing to the interference effect.

Here is the enlarged first quadrant of the log-modulus Fourier-spectrum with 4 decades displayed of the sample image in the original post:
logModSpect_4dec

I didn’t have a look at the spectrum.

Enhancing lines won’t really help in case of the sample image in the original post.

Best

Herbie

I now got a procedure that produces a reletively stable segmentation of my images. There is still room for improvement, but the results are useable. I do

open(input + filename);

// preprocess
run("Set Scale...", "distance=661 known=5 pixel=1 unit=µm");
run("Median...", "radius=2 stack");
makeRectangle(0, 0, 2048, 2040);
run("Crop");
saveAs("Tiff", output + filename);

//threshold and segment
run("Auto Threshold", "method=Mean white");
setOption("BlackBackground", false);
run("Dilate");
run("Open");
run("Distance Transform Watershed", "distances=[Weights (5,7)] output=[16 bits] normalize dynamic=25 connectivity=8");
setAutoThreshold("Default");
run("Threshold...");
setThreshold(0, 0);
run("Convert to Mask");
run("Close");
saveAs("Tiff", output + filename);

it produces something like this (overlay over preprocessed image):

which isn’t 100% accurate and doesn’t detect all biominerals. But it’s good enough for now

1 Like

Good day,

obviously you’ve decided to use a higher spatial resolution, at least your result image has double side length compared of that of the first sample.

However, your macro code is more than strange:

setAutoThreshold("Default");
run("Threshold...");
setThreshold(0, 0);

This means that you first set the automatic threshold according to the “Default”-scheme and you do this again with run(“Threshold…”); and finally you set a fixed threshold at zero and this one is actually applied.

This doesn’t make sense for me.

Finally, it would be interesting to see the corresponding original image that you’ve used and to see the resulting segmentation with a color overlay, because it is near to impossible to judge the segmentation result from the gray overlay.

Regards

Herbie

obviously you’ve decided to use a higher spatial resolution

as I mentioned, I am working on image quality…

here is a current unprocessed image:

However, your macro code is more than strange:

I use an auto threshold. After that I use the Distance transform Watershed from the MorphoLibJ Plugin. the result of this is a grayscale of different particles:

This is why i use a 0,0 threshold afterwards to get a binary image again.

My time is very limited now, so I won’t keep you up to date unless you got more input for me sorry