# How to calculate the radius of curvature for an image of an arc

#1

Hi,

I have an image of an arc of a circle (the interface between two fluids in a micropipette) and I am trying to find the radius of curvature (or the radius of the full circle if extrapolated from the arc). I can work this out manually but I have many images so an automated tool to find an arc and calculate the radius would be incredibly helpful.
I have images such as this one (where the pipette edges are not visible):

Through to images like this one:

I have got as far as simply thresholding and using the find edges tool to create binary images where the arc is visible as a black line but cannot get any further.
Any help would be most appreciated.

Thank you
Tom

#2

Good day,

while the first of your sample images should pose no problems in getting the radius, the second poses several problems of which the geometric distortion is the ugliest.

If possible, the pipette should be captured in a fronto-parallel plane to the sensor plane of the camera.

In any case you should capture and here post uncompressed images in TIF- or PNG-format.
No JPG-format though, because JPG introduces artifacts!
(Converting a JPG-compressed image to TIFF- or PNG-format doesnâ€™t make sense.)
You may also post images as Zip-archives or make them accessible via a dropbox-like service.

Regards

Herbie

PS:
Please have a look at the following ImageJ-macro code:
https://bitbucket.org/davemason/threepointcircumcircle/src

#3

@tom1 I think the following should work:

Ved

#4

Here is an ImageJ-macro that works with your first sample image:

``````// imagej-macro "curvatureRadius" (Herbie G., 05. December 2018)
requires( "1.52i" );
setOption("BlackBackground", true);
w=getWidth();
h=getHeight()-20;
makeRectangle(0,20,w,h);
run("Crop");
setAutoThreshold("Intermodes dark");
h*=0.5;
doWand(0,h);
run("Make Inverse");
run("Interpolate", "interval="+h);
x = newArray(3);
y = newArray(3);
getSelectionCoordinates(xx, yy);
rank = Array.rankPositions(xx);
for ( i=0; i<3; i++ ) {
x[i] = xx[rank[i]];
y[i] = yy[rank[i]];
}
/* the following code is taken from
<https://bitbucket.org/davemason/threepointcircumcircle/src> */
d1=sqrt((x[0]-x[1])*(x[0]-x[1])+(y[0]-y[1])*(y[0]-y[1]));
d2=sqrt((x[1]-x[2])*(x[1]-x[2])+(y[1]-y[2])*(y[1]-y[2]));
d3=sqrt((x[2]-x[0])*(x[2]-x[0])+(y[2]-y[0])*(y[2]-y[0]));
r=(d1*d2*d3)/sqrt((d1+d2+d3)*(d2+d3-d1)*(d3+d1-d2)*(d1+d2-d3));
exit();
// imagej-macro "curvatureRadius" (Herbie G., 05. December 2018)
``````

Paste the above macro code to an empty macro window (Plugins >> New >> Macro) and run it with the sample image open in ImageJ.

HTH

Herbie

#5

Finally here is a much more concise ImageJ-macro that also works with your first sample image:

``````// imagej-macro "curvatureRadius-2" (Herbie G., 05. December 2018)
requires( "1.52i" );
setOption("BlackBackground", true);
makeRectangle(0,20,getWidth(),getHeight()-20);
run("Crop");
run("Find Edges");
setAutoThreshold("Minimum dark");
run("Create Selection");
run("Area to Line");
run("Fit Circle");
getSelectionBounds(x, y, w, h);
exit();
// imagej-macro "curvatureRadius-2" (Herbie G., 05. December 2018)
``````

Paste the above macro code to an empty macro window (Plugins >> New >> Macro) and run it with the sample image open in ImageJ.

It gives me a radius of about 569.5 pixels which appears being a better estimate.

HTH

Herbie

#6

Thank you both, your help is greatly appreciated!

Herbie - I was not expecting anyone to actually write code for me so that is truly appreciated. I am very new to writing code and have only done very simple things so far so you have saved me a good few hours work at least! There are a few useful commands in here that I didnâ€™t know existed so this is all great stuff! I am sure that I can build upon what you have done to get satisfactory measurements for the other images (within the confines of what is achievable with our set-up).
With regards to the image there is not a lot I can do about the quality, the rig we use to get these images is pretty homemade and the micromanipulators do not hold the pipette perpendicular to the light path so the distortion is unavoidable. Also, the software generates the image as a jpg so I am not reducing quality by converting.

Ved - I did not realise that a Hough transform could be used in this way, I thought that it required a full circle! It is interesting that it can and something that I may well investigate in the future.

Cheers
Tom

#7

Also, the software generates the image as a jpg so I am not reducing quality by converting.

Please note that JPG-compression per se is â€śevilâ€ť!

What camera did you use?
What software is it that youâ€™ve mentioned?
Every professional digital camera can deliver images as RAW- or TIF-files.

the micromanipulators do not hold the pipette perpendicular to the light path so the distortion is unavoidable.

The angle in depth I see from your second image is considerable and it will lead to pronouced errors in the determination of the radius.

What you can and should do though is to rectify the geometric distortion in the image as much as possible.

Which optics do you use to capture these kind of images.
Which depth of focus do you get with your setting?

Regards

Herbie

#8

Unfortunately I canâ€™t answer most of what you ask. Most of the components are a few decades old at least and it is owned/looked after by a completely different research group from the one I belong to.
The rig to hold the micropipette is homemade and connected to a microscope stage, it cannot be easily changed without a full re-engineering of the system. The software is a home-written labview project. I do not have the time or experience to try and change itâ€¦
I am using the setup to measure the interfacial tension between fluids in conjunction with other, more established, methods. Previous research carried out has shown that even with the error in the system from the distortion, the values are well within the ranges seen in literature.

#9

What kind of science is this at times of advanced methods and technologies?

Perhaps not your fault, but for someone who spent half his life in laboratories of various kinds it is simply sad to hear what you are telling us here.

Good luck

Herbie

#10

I completely understand. One of my supervisor is obsessed with this kit as he has spent his life using it. I am trying to convince him that I can get the same results quicker and easier using more modern techniques.

#11

One of my supervisor

I understand â€¦
If itâ€™s for a PhD-degree you should remember that you alone are responsible for your work and it is you who decides. Supervisors are mainly meant for your promotion, mainly in the faculty.

Regards

Herbie

#12

Fortunately this is my secondary supervisor so I know I could get away with not doing it, I sort of want to show him it is unnecessary though. His primary students are forced to use this kit for so much stuff and do most of the data analysis manually, this is why I originally asked about ways to speed up the process.