Biggest object measure

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

Biggest object measure

Josep M. Lanau
Hi all,

I am measuring several morphological parameters from fungal colonies.

My first problem is that I need to measure the biggest object in a large
bunch of images  (once calibrated and set to scale) applying a certain
threshold. I know I can adjust  a particle size range in the set measure
options; the problem is that the biggest particle size may vary
enormously from one image to another and there may be a lot of
"satellite" particles that may be very variable in size, also.

I am a quite new user on Image J; I have programmed several simple
macros for batch processing and measuring purposes, but I don't find any
way to achieve this. Any advice will be welcome.

Thank you all in advance.

JM
Reply | Threaded
Open this post in threaded view
|

Re: Biggest object measure

Josep M. Lanau
Hello,

I managed to buid a macro to measure the biggest object of an image. It
uses G.Landini's KeepLargestParticlePixel macro: duplicates the image,
binarizes, deletes all particles except the biggest, selects the object and
measures inside the selection in the original image.

It still does not work, there are some problems when I try to batch measure
a whole directory.

- The results of a previous image is not kept in the results table, so
after batch measuring all the directory, there only remains the last
measure in the results table.
- G.Landini's macro keeps asking in a dialog box if particles are black or
white ones, so you must click once for each image that is measured.

Does anyone have a hint on these?

Here is my macro project (comments in catalan, sorry). It asks for a
threshold level, asks which is the directory to be measured, and asks you
if you want to calibrate before processing (you must click on "global
calibration", then). Hey, it's a beginner's macro!

All coments (if any ;) ) will be welcome. Thank you in advance.

JM Lanau


//                ***** BATCH MEASURE BIGGEST *****
// JML 01-Març-2008

macro "Batch Measure Biggest" {

// setBatchMode(true);

if (nImages>0) {
   getThreshold(lower, upper);
   }
else {
   lower=0;
   upper=255;
   }

Dialog.create("Llindar mínim");
Dialog.addNumber("Threshold mínim",lower);
Dialog.show();
lower=Dialog.getNumber();

Dialog.create("Llindar màxim");
Dialog.addNumber("Threshold màxim",upper);
Dialog.show();
upper=Dialog.getNumber();

    dir = getDirectory("Escull el directori a mesurar");
    list = getFileList(dir);

Dialog.create("Calibrem?");
Dialog.addMessage ("Threshold establert a "+lower+" "+upper);
Dialog.addCheckbox ("Calibrar",1)
Dialog.show();

calibro=Dialog.getCheckbox();

    for (i=0; i<list.length; i++) {
        path = dir+list[i];
        showProgress(i, list.length);
        if (!endsWith(path,"/")) open(path);
          if (nImages>=1) {
                 if (calibro==1) {
                      Dialog.create("ATENCIÓ!");
                      Dialog.addMessage ("Recorda marcar la casella
global!!");
                      Dialog.show();
                      run("Calibrate...");
                      close();
                      calibro=0;
                 }
           
run("Duplicate...", "title=seed.tif");
setThreshold(0, 254);
run("Make Binary", "thresholded remaining black");
run("KeepLargestParticlePixels ");
setThreshold (lower, upper);
run("Create Selection");
run("ROI Manager...");
roiManager("Add");
close();
roiManager("Select", 0);
run("Measure");
roiManager("Delete");
close();
          }
        }
    }

beep();
Reply | Threaded
Open this post in threaded view
|

Re: Biggest object measure

Gabriel Landini
On Friday 30 May 2008 14:08:09 Josep M. wrote:
> I managed to buid a macro to measure the biggest object of an image. It
> uses G.Landini's KeepLargestParticlePixel macro: duplicates the image,
> binarizes, deletes all particles except the biggest, selects the object and
> measures inside the selection in the original image.
> It still does not work, there are some problems when I try to batch measure
> a whole directory.

One suggestion:
Read the measurement you want to keep from the results table and print it in
the log window.

> - The results of a previous image is not kept in the results table, so
> after batch measuring all the directory, there only remains the last
> measure in the results table.

Of course, you call the particles8 each time because you need to know how big
the particles are. You can't have more than 1 results table, so the
suggestion above should work.


> - G.Landini's macro keeps asking in a dialog box if particles are black or
> white ones, so you must click once for each image that is measured.
> Does anyone have a hint on these?

This assumes that all the particles are white and so it will not ask anything
//==================
// assumes white particles
requires("1.30e");
run("Particles8 ", "white  show=Particles overwrite");
// look for Pixels, not Area!

ar=0;
for (i=0; i<nResults; i++) {    
    ca = getResult('Pixels', i);
    if (ca>ar) ar=ca;
}

run("Particles8 ", "white  show=Particles filter minimum=" + ar +" maximum="+
ar +" overwrite");
//==================

Mind the line breaks.
Regards,

Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: Biggest object measure

Josep M. Lanau
In reply to this post by Josep M. Lanau
Thank you very much for your reply, I'll try with your suggestions.
I'll post here the whole routine as soon as it works, for if anyone needs
something similar.
I am also considering which concept is most interesting for my
applications -keeplargestparticle or keeplargestparticlepixel - i am
finding hard to understand the difference. If I don't manage to figure it
out I'll ask you again, if you don't mind.

Thank you again.

JM