Posted by
Jörg Hammel on
Nov 17, 2009; 8:11am
URL: http://imagej.273.s1.nabble.com/Filtering-images-tp3690427p3690431.html
Hi Kay,
I have pasted your macro in another one we use in our lab to process folders
with varying numbers of images (e.g. filtering, mask creation). It is
independent of the number of images in the folder. At the moment the macro
saves the images in bmp format but you can easily change this. You may try
this:
//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 BMP" {convert("bmp");}
//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;
// Instruction
showMessage("Instruction", "Choose source diretory 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);
// 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("Brightness/Contrast...");
setMinAndMax(0, 140);
run("Apply LUT");
run("Sigma Filter Plus", "radius=4 use=3 minimum=1");
setAutoThreshold(); //run("Threshold..."); setThreshold(0,
168);
run("Convert to Mask");
// *** End Insertion specific operations ***
// Save and close images
// Safe and close FILTERED IMAGE
selectWindow(initimage);
//saveAs(format, dir2+list[i]);
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;
}
Best, Joerg
-----Ursprüngliche Nachricht-----
Von: ImageJ Interest Group [mailto:
[hidden email]] Im Auftrag von Kay
Ajayi
Gesendet: Dienstag, 17. November 2009 03:38
An:
[hidden email]
Betreff: Re: Filtering images
Thanks for your contribution. The macros are developed by me. My question is
how can I get the filtered image in imageJ without having a macro. For
instance, the macro is specifically for 1000images. I am just thinking if
i've another set of 1000 images and the appropriateness of that macros is
not questioned. So, I am looking for an option that will be applicable any
image.
On Sat, Nov 14, 2009 at 11:47 AM, Mike Esterman <
[hidden email]> wrote:
> Jorg
> Is your macro published on the Image J website or elsewhere?
>
> Mike
>
>
> -----Original Message-----
> From: ImageJ Interest Group [mailto:
[hidden email]] On Behalf Of Jörg
> Hammel
> Sent: Thursday, November 12, 2009 6:22 AM
> To:
[hidden email]
> Subject: AW: Filtering images
>
> Hi,
>
> If I understood your problem correct, you have a number of images in a
> folder you want to process with the macro you specified below? If your
> images are in standard file format (bmp, jpeg, tiff, etc.) I have a macro,
> which we developed for this purpose to processes all files in a folder and
> saves them to another one after filtering with the same file name.
>
> Best
>
> Jörg
>
>
> -----Ursprüngliche Nachricht-----
> Von: ImageJ Interest Group [mailto:
[hidden email]] Im Auftrag von
> Olukayode Ajayi
> Gesendet: Donnerstag, 12. November 2009 07:55
> An:
[hidden email]
> Betreff: Filtering images
>
> I've about 1000 images and my intention is filter them. Here is a sample
of
> the original image:
http://www.mypicx.com/11122009/Orignal_image/>
> and the sample of the filtered image is
> this:
http://www.mypicx.com/11122009/Filtered_image/>
> Here is my macros:
> run("Brightness/Contrast...");
> setMinAndMax(0, 140);
> run("Apply LUT");
> run("Sigma Filter Plus", "radius=4 use=3 minimum=1");
> setAutoThreshold();
> //run("Threshold...");
> setThreshold(0, 168);
> run("Convert to Mask");
>
> However, if another 1000 images, I'll have to do another macros. How best
I
> can go about do this imageJ which automatically gives me the filtered
> image.
>
> Regards,
>
>
> __________ Hinweis von ESET NOD32 Antivirus, Signaturdatenbank-Version
4598
> (20091112) __________
>
> E-Mail wurde geprüft mit ESET NOD32 Antivirus.
>
>
http://www.eset.com>
>
>
> __________ Hinweis von ESET NOD32 Antivirus, Signaturdatenbank-Version
4598
> (20091112) __________
>
> E-Mail wurde geprüft mit ESET NOD32 Antivirus.
>
>
http://www.eset.com>
>
__________ Hinweis von ESET NOD32 Antivirus, Signaturdatenbank-Version 4613
(20091116) __________
E-Mail wurde geprüft mit ESET NOD32 Antivirus.
http://www.eset.com
__________ Hinweis von ESET NOD32 Antivirus, Signaturdatenbank-Version 4613
(20091116) __________
E-Mail wurde geprüft mit ESET NOD32 Antivirus.
http://www.eset.com