Posted by
Stoyan Pavlov on
Apr 29, 2017; 8:55pm
URL: http://imagej.273.s1.nabble.com/Macro-to-run-Laplacian-on-stacks-tp5018607p5018637.html
Hi,
The problem is that featureJ is producing a new image with name
<originalimage>-Laplacian. And you need to account for that.
I' ve just the macro you need. As a basis I used an old batch processing
macro created by porifera.net. It will ask about source folder, destination
folder and filter size and will process all images in the source folder
with the preselected filter size of the Lap[lacian of Gaussian and save
them to the destination.
Best regards,
Stoyan
//Macro START
//----------------
//Batch Processor
// ***Select macro(s) used here ***
// Just replace "bmp" by "jpeg" or any other standard image file format here
//to select output type of your filtered image
macro "Batch Convert to TIFF" {convert("tif");}
//Function Batch processing
function convert(format) {
requires("1.34m");
// *** General Settings ***
// Close log window if open
if (isOpen("Log")) {
selectWindow("Log");
run("Close");
}
//Variables
var abort,dir1,dir2,dir3,rad,list;
// Instruction
showMessage("Instruction", "Choose source directory containing
source-files \nand destination directories for Filtered IMAGE. \n \nBrougt
to you 2007 by porifera.net\n \n");
// ### Input your values for specific functions here ###
// ### End Input specific functions ###
// Choose directories
dir1 = getDirectory("Choose source image directory ");
dir2 = getDirectory("Choose FILTERED IMAGE destination directory ");
list = getFileList(dir1);
b = getNumber("Gaussian blur radius (in scaled units):", 2);
// Protocol start
print("ImageJ macro 'Batch_Processor' by porifera.net \n \n");
print("initial file source directory: ",dir1, "\n");
print("filtered file destination directory: ", dir2,"\n");
print("Number of files:", list.length, "\n \n");
// Batch processing
setBatchMode(true);
count = 0;
countFiles(dir1);
n = 0;
processFiles(dir1);
function countFiles(dir1) {
list = getFileList(dir1);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], "/"))
countFiles(""+dir1+list[i]);
else
count++;
}
}
function processFiles(dir1) {
list = getFileList(dir1);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], "/"))
processFiles(""+dir1+list[i]);
else {
showProgress(n++, count);
path = dir1+list[i];
processFile(path);
}
}
}
function processFile(path) {
if (endsWith(path, "")) {
open(path);
initimage = getTitle();
// *** Insertion specific operations ***
run("FeatureJ Laplacian", "compute smoothing=&b");
selectImage(initimage);
close();
selectImage(initimage+" Laplacian");
rename(initimage);
// *** End Insertion specific operations ***
// Save and close images
// Safe and close FILTERED IMAGE
selectWindow(initimage);
saveAs(format, dir2+"Laplacian_of_Gaussian_r"+b+"_"+list[i]); //
Safe with a prefix indicating filter radius
close();
//Print progress report
print("processed file ", list[i]);
}
}
//Final message progress report
print("successfully processed ", list.length, " files");
showMessage("Batch processing finished");
}
macro "Abort" {
abort = true;
}
//-----------
//Macro END
---
Dr. Stoyan P. Pavlov, MD, PhD
Departament of Anatomy, Histology and Embryology
Medical University "Prof. Dr. Paraskev Stoyanov", Varna
Prof. Marin Drinov Str.55
9002 Varna
Bulgaria
Tel: +359 (0) 52 - 677 - 052
e-mail:
[hidden email]
[hidden email]
2017-04-26 0:45 GMT+03:00 Ved Sharma <
[hidden email]>:
> You can use Process > Batch > Macro...
>
> Put the run(FeatureJ, options) in the text box and you should be good to
> go. You can use macro recorder to generate this line.
>
> Ved
>
> ___________________________________
> Ved Sharma, PhD
> Department of Anatomy and Structural Biology
> Albert Einstein College of Medicine
> Bronx, New York
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html