User Tools

Site Tools


Courses -2016
Courses 2018-
Downloads (-2016)
Downloads (2016-)
RSS aggregates

EMBL BioImage Data Analysis



—- Contact
CMCI Alumni
EMBL Heidelberg
EMBL Intranet

Popularity Ranking

Timeline of @cmci_

cmci_ avatar

RT @NEUBIAS_COST: NEUBIAS Academy presents two webinars on KNIME for Image Processing March 4th & 11th at 15h30-17h00 CET Register now (si…
About 8 hours, 41 mins ago by: Kota Miura (@cmci_)

cmci_ avatar

RT @katpyxa: @KapiteinLukas @JurriensDaphne Also there was some help from another 3D image analysis expert
About 8 hours, 51 mins ago by: Kota Miura (@cmci_)

cmci_ avatar

RT @haesleinhuepf: @microforum Or, consider linking, mirroring and joining - it's open for collaborators 😃 Many peo…
About 1 day, 8 hours ago by: Kota Miura (@cmci_)

cmci_ avatar

@haesleinhuepf @jmutterer @nevermore_78 I made a trial. setBatchMode("hide"); (or setBatchMode(true);) at the beg…
About 2 days, 2 hours ago by: Kota Miura (@cmci_)

cmci_ avatar

@haesleinhuepf @jmutterer @nevermore_78 Maybe use “batch mode” in behind, just to suppress them to appear on the desktop?
About 2 days, 5 hours ago by: Kota Miura (@cmci_)

cmci_ avatar

@haesleinhuepf @jmutterer @nevermore_78 Hi Robert, Great to have the markdown notebook! Just one thing: would it b…
About 2 days, 7 hours ago by: Kota Miura (@cmci_)

ImageJ Macro Fragments

Some notes on ImageJ macro

Getting the number of Cores

th = eval("script","Runtime.getRuntime().availableProcessors();");

Loading ROIs from a file in Internet

shell command “curl” should be available in your local machine. See here for installation.

run("Blobs (25K)");
path = getDirectory('imagej')+"";
exec("curl", "-LJO", "", "--output", path);
roiManager("Show All");

Ways of getting the file basename

filepath = "/my/path/to/great_image.tif";

//Method 1, string indexing
basename = substring(filepath, lastIndexOf(filepath, "/")+1, lastIndexOf(filepath, "."));
print("Method 1: ", basename);

//Method 2, regular expression
basename = replace(filepath, "(.*\\/)(.*)\\..{3,5}$", "$2");
print("Method 2: ", basename);
//... in this case, it's also possible to get the parent directry just with a small modification
parent = replace(filepath, "(.*\\/)(.*)\\..{3,5}$", "$1");
print(".... parent: ", parent);

//Method 3, use a specific command
//from ver. 1.52r
basename = File.getNameWithoutExtension(filepath);
print("Method 3: ", basename);
//... it's also possible to get the parent directory with a command. 
parent = File.getDirectory(filepath);
print(".... parent: ", parent);

Convert black pixels to white in RGB image

for (j =0; j<getHeight();j++){
	for (i=0; i<getWidth();i++){
		pix =  getPixel(i, j);
		sum = sumRGB(pix);
		if (sum == 0){
			setPixel(i, j, 0xffffff);

function sumRGB(RGBpixval){
	sum = getR(pix) + getG(pix) + getB(pix);
	return sum;

function getR(RGBpixval){
	rf = (RGBpixval & 0xff0000)>>16;
	return rf;       
function getG(RGBpixval){
	gf = (RGBpixval & 0x00ff00)>>8;
	return gf; 
function getB(RGBpixval){
    bf = (RGBpixval & 0x0000ff); 
    return bf;        

documents/201021ijmacrofragments.txt · Last modified: 2021/01/30 11:12 by kota