Some considerations regarding a very classic method : Thresholding
= Why bothering using **Threshold** ? =
Because you would like to identify different kind of object for example
= Should I'll fixe a value an apply the same to all my images=
You can run the code below in ImageJ and get why it may not be such a good idea.
= How do I choose an Algorythm ?=
You can run the code below in ImageJ and know more about the Automatic Method that exist to determine a threshold.
```lang = javascript
// clear the environment
run("Close All");
roiManager("Reset");
//open an image
run("Fly Brain (1MB)");
// make it composite, duplicate one slice and get information
run("Make Composite");
run("Duplicate...", "duplicate channels=1 slices=27");
getDimensions(width, height, channels, slices, frames);
// here we run the Auto_Threshold
run("Auto Threshold", "method=[Try all] white");
getDimensions(output_Width, output_Height, output_channels, output_slices,output_frames);
// I will highlith the categories with some ROIs of different colors
xSize = 258;
ySize = 274;
// so I define the categories and their colors
arrayCatNbr = newArray(1,2,3,1, 2,1,1,3 ,1,2,1,2 ,1,2,2,1)
arrayRoiColor = newArray("50FFFF00", "5000FF00", "50FF00FF");
// adding ROIs
i = 0;
for (x = 0 ; x < output_Width ; x+=xSize){
for (y = 0 ; y < output_Height ; y+=ySize){
makeRectangle(x, y, xSize, ySize);
Roi.setName("Cat-"+arrayCatNbr[i]);
Roi.setFillColor(arrayRoiColor[arrayCatNbr[i]-1]);
roiManager("Add");
i++;
}
}
// Sort the ROi and Tile the images
roiManager("Sort");
run("Tile");
selectImage("Montage")
roiManager("Show All");
```