Quantcast

calculate white area percentage

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

calculate white area percentage

zahidkjatoi
Hello ImageJ experts,

I am new to imageJ. I was writing a macro that will (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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: calculate white area percentage

vega
Hi khan
I do not know how to make macros in ImageJ... yet, but I've calculated the white area percentage with this program. I'understood you want to calculate that. You don't need to set scale because you can make the percentage whith pixels. the whole area of the image is in the image information. To obtain the white area you have to use the threshold. Select the area and then apply measurement. The percentage is 100*white area in pix^2/total area in pix^2. I hope it helps you
Loading...