Convex hull perimeter usage

@noahjp Excuse me , Can you teach me how to get a Convex Hull Perimeter. I don’t know how to get it in program.
I use Fiji and ImageJ. I need CH Perimeter for my thesis. Thanks

Hi
@Poon_Aunmongkolmit

Are you talking about this?
Edit–>Selection--------->Convex Hull

or the length of the outline of the figure (called perimeter )?

@Mathew Thank for reply
Yes I know that
Edit->Selection->Convex Hull
but I don’t know how to do after click that

I want to know the length of the outline of the figure. My lab test is shape and roughness of soil particles by image analysis 2D, so I need to know how to get convex hull perimeter for calculate a parameter “roughness”. Shape of particle I can calculate them by perimeter and area of particle(I got them). Now the Convex Hull Perimeter is unknow for me, I don’t know how to use imageJ of Fiji to get it. Can you teach me please ?
I saw the results “Example_1.bmp” I want to get it.

Hi
@Poon_Aunmongkolmit
I don’t know if that answers your question?

newImage("Untitled", "8-bit ", 512, 512, 1);
run("Set Measurements...", "perimeter redirect=None decimal=2");
makePolygon(104,140,195,91,205,148,314,126,306,192,375,201,298,272,242,177,146,268,153,176);
roiManager("Add");
roiManager("Set Fill Color", "black");
roiManager("Show All without labels");
run("Flatten");
roiManager("Select", 0);
roiManager("Measure");
run("Convex Hull");
roiManager("Add");
roiManager("Select", 1);
roiManager("Measure");

@Mathew Sorry, I don’t understand : (
Your answers means I have to draw Polygon or something by myself ?

This is my method






Could you advise me anything else ???
I don’t know to get CH Perimeter : (

1 Like

@Mathew
I know this but I don’t understand how does it work ???

@Poon_Aunmongkolmit
Can you save an original image on the forum?

I not sure I understand what’s you want to convey.
What’s original image ??

@Poon_Aunmongkolmit
Paste the above macro code to empty macro window (Plugin->New->Macro) and run and
with this image open in ImageJ

//setTool("rectangle");
makeRectangle(613, 0, 140, 120);
run("Crop");
run("8-bit");
setAutoThreshold("Yen dark");
//run("Threshold...");
//setThreshold(38, 255);
setOption("BlackBackground", true);
run("Set Measurements...", "perimeter redirect=None decimal=2");
run("Analyze Particles...", "size=100-Infinity display add");
roiManager("Select", 0);
run("Convex Hull");
roiManager("Add");
roiManager("Select", 1);
roiManager("Measure");

@Mathew I’ll try, Thank a lots ^___________^

@Mathew
I try but it doesn’t work : (
I don’t know how to get them, what happening ???


The macro works with image I put (taken from yours) because I couldn’t do anything with your screenshot
Try with the picture I put.
If you want something different please send the source picture you want to work with

@Mathew I’ll try in another way, thanks a lot

Macro for the image above.

requires("1.52t");
setBackgroundColor(0,0,0);
setOption("BlackBackground",true);
img=getImageID();
setBatchMode(true);
selectImage(img);
run("Duplicate...", " ");
run("8-bit");
setAutoThreshold("MaxEntropy dark");
//run("Threshold...");
setOption("BlackBackground", true);
run("Convert to Mask");
run("Set Measurements...", "perimeter redirect=None decimal=2");
run("Analyze Particles...", "size=100-Infinity display add");
n=roiManager("Count");
print(n);

// Create an Array to stock real perimeter
perimArray1=newArray(n);
for(i=0;i<n;i++)
{
roiManager("Select", i);
//roiManager("Measure");

// Store real perimeter in the created array
perimArray1[i]=getResult("Perim.", i);
}

// Show Array1
 Array.show(perimArray1);

run("Clear Results");

// Create an Array to stock convex perimeter
perimArray2=newArray(n);
roiManager("Show All without labels");
for(i=0;i<n;i++)
{
roiManager("Select", i);
run("Convex Hull");
run("Measure");

// Store  convex perimeter in the created array
perimArray2[i]=getResult("Perim.", i);
}
// Show Array2
 Array.show(perimArray2);
run("Clear Results");

// Create the table and compile the measurement values
Table.create("Perimeter");
// set a whole column
Table.setColumn("Real",perimArray1);
Table.setColumn("Convex",perimArray2);
setBatchMode(false);
close("*");close("Log");close("Results");close("perimArray2");close("perimArray1");
exit("It's over");
1 Like