split channel batch processing for particle analysis

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

split channel batch processing for particle analysis

Steve83
Hi ImageJ mailing list,

I need to analyze particle surface areas from a whole batch of images. My workflow is as follows:

- setting the scale
- creating a rectangle defining the area of interest (where I want to investigate the particles)
- converting to 8-bit
- applying a threshold
- analyze particle size
- save cropped and threshold image for further analysis

Due to low contrast etc., none of the available auto thresholds can reasonably distinguish between particle and "non-particle". BUT if I split the RGB channels of the image I want to analyze in advance, discard the green and the blue channel and use only the red channel for all further process steps, I get really satisfying results. Unfortunately I don't know how to implement this action to the batch process:

- split channels
- waste the green and the blue channel image
- perform all further action only with the red channel image

I would be really grateful to get some help. Please see below my code used to perform the above mentioned action. Ideally the splitting/wasting action i am asking for is implemented directly after the cropping.

Best,
Steve


setBatchMode(true);

inputFolder = getInfo("image.directory");
images = getFileList(inputFolder);

outputFolder = getInfo("image.directory")+ File.separator + "processed_IMG"+File.separator;
File.makeDirectory(outputFolder);
run("Close");

// loop for all files in folder
for (i=0; i<images.length; i++) {
        showProgress(i, images.length);
        inputPath = inputFolder + images[i];

        if(isImage(inputPath)){
        open(inputPath);
    origIMG = getInfo("image.filename");

        // scale IMG
        run("Set Scale...", "distance=640.54 known=20 pixel=1 unit=mm");

        // create spot of interest
        makeRectangle(2700, 564, 252, 2058);
        run("Crop");
        // save cropped image
                run("Duplicate...", "title=[origIMG]");
                suf = "_crop";
                suffix = ""+suf+".jpg";
                newIMG = replace(origIMG,".JPG",suffix); //case sensitive!
                saveAs("Jpeg", outputFolder + newIMG);
                close();
       
        // imageprocessing
        run("8-bit");
        run("Auto Threshold", "method=Minimum");
        run("Convert to Mask");
        run("Analyze Particles...", "size=0.036-Infinity circularity=0.00-1.00 show=Nothing display exclude include");

        suf = "_mask";
        suffix = ""+suf+".png";
        newIMG = replace(origIMG,".png",suffix); //case sensitive!
        saveAs("PNG", outputFolder + newIMG);

        close();