Multi-point pixel selections for an entire folder of images



I have a folder full of images. Each image has maybe ten features in it. I would like to have a macro which does the following.

  1. Requests image directory

  2. Loops through each image in directory, and
    a) opens the image
    b) pauses while I make click multiple points of interest in the image
    c) extracts the pixel coordinates x,y at each click
    d) appends [image_name, x,y] to an output list
    e) closes the image when I am done

  3. returns the output list as a csv file after all images have been iterated through

The form of the output should be:

fname1, x11, y11,
fname1, x12, y12,

fname2, x21,y21,



Any guidance is appreciated; I’m an imageJ layman. I searched around and was not able to find a simple solution



To get you started… check out this older post for another user… You can also check out the following links - which have a nice outline of code you could use & modify to do as you wish:


Thanks @etarena
Patching together some various things / actively making things up leads me to this. Do you have any guidance for me off of these lines? Thanks!

files = getFileList(input);
for (i = 0; i < files.length; i++){
	filename = files[i];
	key = File.nameWithoutExtension;
	for (j=0; j< nResults; j++){
	    x = getResult("X", j);
	    y = getResult("Y", j);
            List.set(key, (x,y));     
saveAs("List", output+"Results.csv");

Currently the code opens images and waits for my input as expected, but the input is not being properly recorded or saved.


define input path as input and output path as output

nr = 0 
run("Clear Results");
files = getFileList(input);
for (i = 0; i < files.length; i++){
    filename = files[i];	
    open(input + filename);
    waitForUser("find features on image" + filename);
    for (j=nr; j< nResults;j++){
        setResult("image filename", j, filename);}
    nr = nResults;

saveAs("Results", output);