ImageJ: Fibre counting

Hi everyone,

I am trying to count textile fibre with ImageJ. I have blue fibres on a white garment.
Playing with the threshold Color, I can isolate my fibres, however sometimes, as you can see on the image, there is holes within one single fibre. This is causing me an issue, especially when I want to count these fibres manually: instead of having one output, I will have 3.
Does anyone have an idea to improve the counting?

Thank you !

Hi Vgalais,

Could you upload an original file so we can help you better?

From what you are describing, your segmentation method may need a bit of tweaking. Furthermore, once you obtain your binary image, you may want to use the Dilate function to re stitch the fibres.

Sincerely,

M.

Hi Matthieu,

Thanks for your reply. I uploaded a the whole photo, the previous one was a zoom. Hope it will help.
When you said binary image, are you talking about converting the image into 8bit? Sorry ImageJ is pretty new for me.

Best,

Virginie

There are at least two problems with this image that make the analysis more complicated than necessary and in any case reduce the quality of analysis:

  1. The image appears being taken by a cell-phone camera.
    These cameras are optimized to give nice looking images but not images for quantitative analysis.
    Use a dedicated camera instead.
  2. The lossy JPG-compression of the image introduces artifacts that make the desired analysis difficult and partially impossible.
    Provide images in an uncompressed format.

Here is a color-excerpt that may serve as a starting point.


Such kind of image could successfully be thresholded if the image quality is improved.

1 Like

Hi notQRV,
Thank you for your help.
The image was taken by a nikon camera and a macro lens. I don’t know how to deal with RAW file (.NEF with Nikon) with imageJ, this is why I converted it into JPEG. I can’t send the raw image here directly so here is a WeTranser link (this is not the same image, but take in similar condition) : https://we.tl/t-QAPJsGzSag

Best,

Virginie

Thanks for the link to the original image.
This camera should be well-suited!
16bit and higher spatial resolution will definitely help with the analysis.

I’m just struggling with the image format …

I shall try to provide a result tomorrow.

The downloadable image is not the one you’ve posted in JPG-format.
It shows a different tissue with easily detectable fibers.

Please make available the original image with the blue fibers.

1 Like

I apologize, I must have deleted the RAW file, however I still have the converted JPEG file with still a high quality. Please find it here : https://we.tl/t-tIjyDgkA5Z

Hi Virginie,

I can see why you’re having to convert to jpg as Fiji struggles with .nef files. However, you can convert your nef files to .tif here: NEF (RAW) to TIFF (Online & Free) — Convertio

Anyway, once the tif file is opened, you need to do the following:

Go to Plugins>New>Macro and paste the following code:

roiManager("reset");
Title=getTitle();
waitForUser("Define Area", "Please use the rectangle tool to define an area free of shadows then click OK");
run("Crop");
run("Duplicate...", "duplicate");
rename(Title+" Fibres");
run("Properties...", "channels=3 slices=1 frames=1 pixel_width=1.0000 pixel_height=1.0000 voxel_depth=1.0000");
run("Split Channels");
close("C3-"+Title+" Fibres");
close("C2-"+Title+" Fibres");
selectWindow("C1-"+Title+" Fibres");
run("Grays");
run("Find Edges");
run("Median...", "radius=2");
setOption("BlackBackground", true);
setThreshold(8000, 65535);
run("Convert to Mask");
run("Analyze Particles...", "size=700-Infinity circularity=0.00-0.5 display summarize add");
selectWindow(Title);
roiManager("Show None");
roiManager("Show All");
roiManager("Set Color", "blue");
roiManager("Set Line Width", 0);
setForegroundColor(255, 255, 255);
run("Flatten");

You should have your picture with the fibres highlighted and a window called “Summary” where the number of fibres is under “Count”.

One could automate this further if all the tif images were in a folder.

Sincerely,

Matthieu

3 Likes

Hi Matthieu,

I just tried the macro you sent with a .tiff but an message came as : The product of channels (3), slices (1) and frames (1) must equal the stack size (1). And I end up with a duplicate of what I had in the first place
I there any step I fogot to do before?

Thank you,

Virginie

Hi Virginie,

The issue is the .tif file you’re testing the macro with. Did you get it from Convertio or is it using a different convertion method? The .tif I got opened as a 3 channel 16bit file, is yours RGB?

If it is RGB, put “//” ahead of the line that starts with “run(“Properties…”,…”

Sincerely,

Matthieu

1 Like

Hi,

It was in RGB after the convertion. I added the “//” and it seems to work ! thank ou very much for your help :grinning: !

Kind regards,

Virginie

1 Like