How to program a macro to get angles from three points using multipoint, (law of cosines)

Hello Forum,

Hope that you are all fine. I’m not very advanced with ImageJ, I hope you guys can help. I have sets of images with structures (figure) I need to find the angle between center points of structures. Of course I can use angle tool and measure the angle, but since there are so many structures, I want to write a program so that user gets the angle by clicking center of the structures using muliti-point.

I didn’t do a lot of programming in ImageJ just by digging in Built-in Macro Functions in imagej website i started my code as following,

if (!isOpen("Log"))
	print("Instructions:\n  Select three points\n ");

// open an image
Imagename = File.openDialog("Open an Image to analyze");
if (Imagename=="")
	exit();
write("Image name = "+Imagename);
open(Imagename);
getPixelSize(unit, pw, ph, pd);

// User Selects three points
setTool("multipoint");
run("Select All");	
waitForUser("ROI Selection", "Select Points");
getStatistics(area, mean, min, max);
run("Measure");

I want to know how to define my equations and get the data from measured box.
Your help is appreciated.

1 Like

Hi @R_M,

there was an earlier post he on the forum by @dnmason , which might be helpful for you:

Cheers,Robert

So are you also trying to get data on the centers as well? I am unclear as to why you are using getStatistics. Will you be wanting to get all angles or just specific ones?

Good day,

did you search the Forum for “Law of Cosines”?

Please consider this post for a start:
https://forum.image.sc/t/angles-and-distances-calculation-in-multipoint-tool/21659/5?u=herbie

Regards

Herbie

2 Likes