Extracting cosmic rays on dark exposures

imagej

#1

Hello,

im am very new to ImageJ and need some help.

I am currently doing an experiment where a camera is taking dark exposures in a light sealed box for capturing cosmic rays and natural background radiation. The radiation shows up as dots and lines in the pictures (see images).
I collected already a few hundert hours of data (thousand of pictures).
Fortunately I found now ImageJ with the “Analyze Particle” function that works great for finding the cosmic rays automatically in the images.
In the past time I opened every image manually in Photoshop and searched for the particles, than cropped it and saved them. This worked well, but was an extremely time consuming process.

My hopes are now to do this process all automatically in batch process.

Example:
the images from the camera are stored in daily folders like so:

2019_02_13
2019_02_14
2019_02_15

I want now, that ImageJ opens the images, finds the particles (cosmic rays an radiation) and saves the findings as a *.tiff file.
The program should create a bounding box around the ROI with about 30px larger, than crop the RIO, scaling the large side of the ROI to 1000px (interpolation: “none”) and finally saving the particle as a *.jpeg file. The important thing is, that it should do that with every particle in the image.

Example:
if ImageJ finds 5 cosmic rays in a photo, it should save them as 5 individual .jpeg files.

I tried it already with macros, but didn’t got it to work, especially for saving the RIO individually.

finding particles was not an issue:

Example pictures:

full frame:

crops:
_ISO-1600_00062_crop

traces_2018_11_13_14_49_14_000000299_crop

traces_2018_11_16_19_26_08_000001700_crop

Here are my steps in ImageJ, got good results with that:

run("Duplicate...", " ");
run("Find Edges");
run("Smooth");
run("Smooth");
run("Smooth");
run("Enhance Contrast...", "saturated=0.1");
run("8-bit");
setAutoThreshold("MaxEntropy");
//run("Threshold...");
//setThreshold(0, 124);
setOption("BlackBackground", false);
run("Convert to Mask");
run("Invert");
run("Analyze Particles...", "size=110-Infinity pixel show=Outlines add");

Many thanks in advance!


Saving each ROI as individual images
#2

So, what part of the process do you need help with? Its not entirely clear to me since you seem to already have a script for identifying the rays.


#3

Everything is working now. The problem was to save all ROI found in picture as individual tiff.

here is the script:

The last thing what I need is a command that deletes the original image afterwards the batch process is finished?

setBatchMode(true);
input = “S:\data_input\”;
output = “S:\detections_output\”;
list = getFileList(input);

for (i = 0; i < list.length; i++){
print(input + list[i]);
open(input + list[i]);
mainTitle=getTitle();
dirCropOutput=output+File.separator+mainTitle;
File.makeDirectory(dirCropOutput);
run(“Duplicate…”, “title=particles”);

    run("Find Edges");
    run("Smooth");
    run("Smooth");
    run("Smooth");
    run("Enhance Contrast...", "saturated=0.1");
    run("8-bit");
    selectWindow("particles");
    setAutoThreshold("MaxEntropy");
    setOption("BlackBackground", false);
    run("Convert to Mask");
    run("Invert");
    run("Analyze Particles...", "size=110-Infinity pixel show=Outlines add");

    selectWindow(mainTitle);

    for (u=0; u<roiManager("count"); ++u) {
        run("Duplicate...", "title=crop");
        roiManager("Select", u);
        run("To Bounding Box");
        run("Enlarge...", "enlarge=30 pixel");
        run("Crop");
        saveAs("Tiff", dirCropOutput+File.separator+"detection_"+(u+1)+".tif");
        close();
         //Next round!
         selectWindow(mainTitle);
    }
    close();
    selectWindow("particles");
    close();
    roiManager("reset")
   // print("finished");    

}


#4

By “delete”, I assume you mean “close”? If so, then I don’t understand as it looks like you are also already doing that. Or perhaps you really do intend to delete the file?