Quantcast

Calculate white area percentage

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Calculate white area percentage

zahidkjatoi
This post has NOT been accepted by the mailing list yet.
Hello ImageJ experts,

I am new to imageJ. I was writing a macro that will calculate white area percentage (Surface coverage) of *.bmp files automatically. These images are black and white, as attached sample below. Below is the macro which i created but i could just see one image area percentage, not all. Can you guide me how to make it correct?



**************ImageJ Macro*******************

dirX = getDirectory("Bilderpfad");  
list = getFileList(dirX);      

var temp_list_length=0;      
var temp_i      


for (i=0;i<list.length;i++)
{
        open(dirX+list[i]);
        if(endsWith(list[i],"bmp"))
                {
       
                        run("16-bit");
                        setAutoThreshold("Default dark");
                        run("Set Scale...", "distance=1.0 known=0.317458717773152 pixel=1.0 unit=um global");    
                        black = 0;
                        white = 255;
                        getHistogram(0, hist, 256);
                        total = 0;    
                for (i=0; i<256; i++)
                        total += hist[i];
                        print("");
                        print("Percent white:" +100*hist[white]/total);
                       
                                       
        }
       
       
}

for (i=0;i<list.length;i++)      
{
        if (endsWith(list[i],"bmp"))      
        {
                print(list[i]);    
                temp_list_length++;
        }
}

*******************************************
Thank you very much,

Khan.
Loading...