Automatic ROI on camera plasma image

Hello. I have just found my way to ImageJ and thought it might be usefull to process a dozen of images like these.

Of course first I need to crop to only hold the purple-ish circle.
The images come from a ueye camera in a setup which produces plasma in cavities.
I want to measure the mean intensity in all chambers by automatically placing (and defining) ROI’s in the cavities.

I am not sure where to start. I played with adjust color threshold and analyse particles to automatically create ROI’s. But then I end up with cavities which are either totally black or white and thus the average ROI intensity is 0 or 255.

I am not sure in what way to proceed.
If a cavity is lit (purple-ish) I could detect it by checking intensity.
But if it were not lit I would maybe need to go for template matching to find the edges of the cavities.

Could someone point me in the right direction?
I know RTFM but it is so big!
Or do I need a beginners course ImageJ first :fearful:

You probably want to look into posts discussing the transfer of ROIs back to the original image after analyze particles.

If you are having trouble with choosing the correct region, Weka segmentation is also an option as a pixel classifier to create the masks. There are quite a few posts on that topic as well, and might give you a more precise outline of the area you want to measure.

It looks like this is an RGB image and not any kind of measurement channel (fluorescence, single channel, detector etc), so “intensity” is going to be a bit rough, dependent on the angle, color, etc. I would guess you are aiming for the “grey-scale” intensity?

Thanks for the pointer. I will search the forum for ROI transfer.


Still thinking about intensities. I want to score the cavities in 5 mean intensity ranges.

As you can see here sometimes a cavitiy has no plasma (3) so those will be scored with a 0. Others are less bright (1) than e.g. (10).

That is why I was also thinking of template matching since it would be hard to detect cavities when they are off (Like 3).

Hi
@corvus
I allow myself to introduce myself in this discussion.
Is this what you want to achieve?
If so then it is doable.
Thank you
ROI auto

This is indeed what I was looking for! :smiley: Each ROI should then somehow end up in the ROI manager (I think) so then I can get 12 measurements of intensity.

Test and report
Please

//setTool("oval");
makeOval(206, 510, 192, 188);
run("Crop");
run("Select None");
run("Duplicate...", "title=1");
run("Duplicate...", "title=2");
run("32-bit");
run("Enhance Contrast...", "saturated=10 normalize");
setAutoThreshold("Minimum dark");
//run("Threshold...");
setOption("BlackBackground", true);
run("Convert to Mask");
run("Set Measurements...", "area display redirect=None decimal=2");
run("Analyze Particles...", "size=300-Infinity display exclude add");

selectWindow("1");
roiManager("Show All without labels");
run("Set Measurements...", "mean display redirect=None decimal=2");
roiManager("Select", newArray(0,1,2,3,4,5,6,7,8,9,10,11,12));
roiManager("Measure");
run("Tile");
selectWindow("Results");
1 Like

@Mathew
Thanks a lot for your help. I really appreciate it. It does not work yet but I am sure I will get there.
I have a feeling that my input picture has a different size since I end up with 3 windows with a very small part of the picture.

Then some really noob questions.
I guess every part of the macro should have a equivalent in the GUI menu, right?
So to understand what is going on I can do the same thing with the GUI.

@corvus

I took your first image.
To understand the process take the time to do one line at a time.
Line after line
This is how I learned.

But we remain available.
Good luck.

@Mathew
Hi I managed to use macro debugging and found all except 1 commands in the GUI
In the part up to select window(1)
I tried to google it but it did not give me a solution.

Where can I find the setOption(“BlackBackground”, true);
Is it part from Make binary?
image

1 Like

@corvus

//setTool("oval");
makeOval(206, 510, 192, 188);
run("Crop");
run("Select None");
run("Duplicate...", "title=1");
run("Duplicate...", "title=2");
run("32-bit");
run("Enhance Contrast...", "saturated=10 normalize");
setAutoThreshold("Minimum dark");
//run("Threshold...");
setOption("BlackBackground", true);
run("Convert to Mask");

Replace
setOption (“BlackBackground”, true);
by
setOption (“BlackBackground”, false);
and you will understand the difference.

yes

It appears as if the image is taken with a smartphone camera which is a bad choice if you do scientific image evaluation and especially if you are interested in light intensity measurements.

Do you expect the image values taken with a smartphone camera to represent the light intensities?

If so, you are wrong.
Smartphone cameras do a lot of computation to present images that are pleasant for the eye but they are unsuited for quatitative evaluations. (The image processing of smartphone cameras is generally not specified.)

Do you know where the focus of a smartphone camera is?

Although smartphone cameras show a considerable depth of focus, it is not the same throughout this depth …

In any case, use a dedicated (machine vision) camera showing a gamma of one or at least a professional camera with defined gamma (that allows for gamma correction) with appropriate optics.

Furthermore, you should have access to the raw data from the camera that must not be compressed in a lossy fashion. JPG-format is unsuited and post hoc conversion of JPG-images to a non-lossy format doesn’t change the situation.

If you have a suitable camera, then use a solid stand to position it in a reproducible way with respect to the object.
If the camera has a defined gamma != 1, then don’t forget about gamma correction of the images, otherwise any intensity measurements are useless.

Good luck!

1 Like

@notQRV

Yes the posted image could be an image of my smartphone but as I mentioned in the original post I am planning to make a setup with the Ueye UI-3860LE-C-HQ which IS an industrial camera. It is mounted on a dark tube with a fixed distance.
I realise that jpg is a lossy compression technique and that I need lossless images from the camera like png. Also I need to fix the camera exposure settings so I can compare intensities.
The only thing in the setup which can vary is the rotation of the underlying disc with cavities that makes it a little bit more complex.

Initially I was thinking of using Labview Vision software to do pattern recoginition and find the cavities and place the ROI’s.

However in the feasability phase I could first try to manage with FIJI.

Thanks you though for the warnings and caveats.

It may be noteworthy that the camera in question is a 36bit RGB-device and as such it may require 48bit RGB import and perhaps even processing which isn’t perfectly supported by ImageJ.

The gamma of the camera in question can be set, at least per acquisition software but perhaps even per download to the camera-hardware. In any case, make sure that the images used for analysis were acquired with a gamma of one or at least with a defined and known gamma, otherwise you will not be able to obtain reasonable intensity measurements.

By now I played with the software and I find more and more functions.
I can automatically generate the ROI and generate mean intensity in the ROI’s

I am still puzzled by the ROI manager.
I have a list of ROIs and choose to save it in the ROI manager.
However when I tried to open the ROIs again I found that it only saved 1.
I tried selecting them all and then save them but it still resulted in 1 ROI.

image

When I choose more–> Open I get
image

Am I missing the purpose of the ROI manager?

Hi
@corvus

To measure all your ROIs you can use this:

@Mathew
Hi Mathew. Thanks for the reaction but this is not what I meant.
Suppose I close ImageJ and next time I want to load these ROIs again on a similar picture.
I just want to save the 12 ROI’s so I can open them without doing the Analyzer particles part to automatically find them.

I think he was demonstrating that you need to select what you want to save. Otherwise, yes, you are only saving one of your ROIs.

2 Likes

@Research_Associate
Great! I had never explored this route. Works very well
Allow me to supplement with what I tested.
@corvus

roiManager("Save", "------------------------------------/RoiSet.zip");

Add this at the end of the 1st macro.

“---------------” will be the name of your file

Then I use this for any image (taken under the same conditions as the first)

//setTool("oval");
makeOval(206, 510, 192, 188);
run("Crop");
run("Select None");
rename("1");
roiManager("Open", "----------------------------------/RoiSet.zip");
selectWindow("1");
roiManager("Show All without labels");
run("Set Measurements...", "mean display redirect=None decimal=2");
roiManager("Select", newArray(0,1,2,3,4,5,6,7,8,9,10,11,12));
roiManager("Measure");
run("Tile");
selectWindow("Results");


Go to “more” then “save”

thanks to @Research_Associate

2 Likes

Hi All,

It worked after all. Sorry for all the confusion.
I was so focussed on the first AllROIs.roi file that I did not notice the ROIS.zip file which was created.
So for all other beginners a recap.

In the ROI manager
Either select ALL ROIs or select NONE at all (deselect button) --> goto more and click save. A zip file will be created.
Just like it literaly says in the documentation:
Save… Saves the selected ROI as a .roi file. If no ROIs are selected, saves all the ROI Manager selections in a ZIP archive.

2 Likes