Batch job to apply different number for each images

Hello CP,

I have images for 65 days and 144 images for each dates.
I am trying to remove noises from those images using “Remove Outliers”
When the function of “Remove Outliers” is processed, Radius# is needed.
For some reasons, I need to apply different number of Radius for each images.
These numbers are from Plot Profile. I have all numbers but I don’t know how to apply those numbers to batch job for “Remove Outliers”.

Is there any method I can apply?

Here is my code to process all images in all subfolders.

// To process all tif images in all subfolders

input = getDirectory(“Choose Source Directory”);
suffix = “.tif”; //you only want to apply to tiff images, no need to ask
processFolder(input);
function processFolder(input) {
list = getFileList(input);
for (i = 0; i < list.length; i++) {
if(File.isDirectory(input + list[i])) //if it’s a directory, go to subfolder
processFolder("" + input + list[i]);
if(endsWith(list[i], suffix)) //if it’s a jpg image, process it
processFile(input, list[i]);
//if it’s neither a jpg nor a directory, do nothing
}
}

function processFile(input, file) {

print("Processing: " + input + file);
open(input + file);  //open image

run("Remove Outliers...", "radius=25 threshold=1 which=Dark");
run("Analyze Particles...", "summarize include holes");

close("*.tif");

}

The radius number is 25 in this code. As mentioned I need to apply different number for each image.
Please check this out to help

Thanks a lot in advance.

IJ Beginner

If the settings are very variable then a different image processing component might give you better results. Could you post some example images? Then we could test a bit :slight_smile:

The remove outliers is good for removing hot or dead pixels, pixels that deviate dramatically from the median grey value in the image. Is that what you want to achieve?

1 Like

Thanks schmiedc,

Here is the 2 sample images.
1.tif (11.4 MB) 2.tif (11.4 MB)

I want to apply 29.1 radius for 1st image and 1.4 for 2nd image.
These numbers came from Plot Profile.
I am not sure these are possible to make macro because there are thousands images to analyze.
I hope there is a way to figure this out.

Thanks again

Hi,

as I said, the remove outliers function is used for removing hot or dead pixels.

You seem to have a binary image where it seems that you want to filter structures. Or at least that would be the effect of using the remove outliers function in this case. If I misunderstand your problem please correct me or indicate what you want to achieve!

Why don’t you use binary functions or the size and shape filter of the Analyze particles ? With this you will also be able to filter the particles in your images and might achieve a more robust workflow.
https://imagej.nih.gov/ij/docs/guide/146-29.html#sub:Binary
https://imagej.nih.gov/ij/docs/guide/146-30.html#sub:AnalyzeParticles

Cheers,
Christopher