Screening of images in stack import - ignoring certain

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Screening of images in stack import - ignoring certain

burt46
Hi,

I am importing timelapse images as a stack from a folder, all images were taken at a fixed camera position. However, i have a problem whereby the sun position at a certain time of day generates a white out on some images. Rather than manually delete these before importing the stack is there a way that ImageJ can pre-filter images of a certain threshold and chose not to import them or not to include them in a post process analysis?

Thanks in advance.



 
Reply | Threaded
Open this post in threaded view
|

Re: Screening of images in stack import - ignoring certain

Rasband, Wayne (NIH/NIMH) [E]
> On Jan 2, 2016, at 8:15 AM, burt46 <[hidden email]> wrote:
>
> Hi,
>
> I am importing timelapse images as a stack from a folder, all images were
> taken at a fixed camera position. However, i have a problem whereby the sun
> position at a certain time of day generates a white out on some images.
> Rather than manually delete these before importing the stack is there a way
> that ImageJ can pre-filter images of a certain threshold and chose not to
> import them or not to include them in a post process analysis?

You can do this using a macro like the one below. It asks the user to choose a folder, imports all the images in the folder as a stack and then deletes the images in the stack that have a threshold exceeding a specified value.

-wayne

  threshold = 1000;
  dir = getDirectory("Choose folder");
  run("Image Sequence...", "open=&dir sort");
  for (i=nSlices; i>=1; i--) {
    setSlice(i);
    setAutoThreshold("Default dark");
    getThreshold(t1, t2);
    msg = "";
    if (t1>threshold) {
       run("Delete Slice");
       msg = "(deleted)";
    }
    print(i, t1, msg);
  }
  resetThreshold;


> --
> View this message in context: http://imagej.1557.x6.nabble.com/Screening-of-images-in-stack-import-ignoring-certain-tp5015306.html
> Sent from the ImageJ mailing list archive at Nabble.com.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Screening of images in stack import - ignoring certain

burt46
Thanks Wayne,

I get an error on line 6:

setAutoThreshold("Default dark");

I presume this is a conflict with line 1. I commented it out and it seemed to run okay. Would this be correct?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Screening of images in stack import - ignoring certain

burt46
For anyone searching a similar solution, the following worked for me for an RGB Image

  threshold = 25;
  dir = getDirectory("Choose folder");
  run("Image Sequence...", "open=&dir sort");
  for (i=nSlices; i>=1; i--) {
    setSlice(i);
    getRawStatistics(nPixels, mean);
    msg = "";
    if (mean>threshold) {
       run("Delete Slice");
       msg = "(deleted)";
    }
    print(i, mean, msg);
  }
  resetThreshold;