How to analyse a pattern of holes?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

How to analyse a pattern of holes?

BillyWu
Hi guys. I'm doing my MSc thesis and I'm using ImageJ software to look at measuring shotgun spread patterns. Basically, I have a white paper target that I've photographed and I know the dimensions of the paper. Setting the scale is easy :)

what I need to know is how can I use ImageJ to draw a circle of best fit around my shot grouping? I need to analyse it with image software rather than using my own interpretation, so if I could find a method that accounts for 95%> of my spread pattern and then fits a circle of best fit to it then that'd be perfect :)

Could anyone tell me how to do this please?
Reply | Threaded
Open this post in threaded view
|

Re: How to analyse a pattern of holes?

Krs5
I would measure the total number of pixels from the shot grouping. Make a maximal circle and decrease the circle diameter while measuring the shot grouping at each diameter. You could use something like

run("Select All");
run("Fit Circle");
run("Enlarge...", "enlarge=-25");
measure

The value -25 depends on the size of your image and how accurate the measurement has to be. You could do this till the value is < 95% and then enlarge with smaller numbers till the value has become >95% again.

Best wishes

Kees


Dr Ir K.R. Straatman
Senior Experimental Officer
Advanced Imaging Facility
Centre for Core Biotechnology Services
University of Leicester
http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif



-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of BillyWu
Sent: 04 August 2015 21:40
To: [hidden email]
Subject: How to analyse a pattern of holes?

Hi guys. I'm doing my MSc thesis and I'm using ImageJ software to look at measuring shotgun spread patterns. Basically, I have a white paper target that I've photographed and I know the dimensions of the paper. Setting the scale is easy :)

what I need to know is how can I use ImageJ to draw a circle of best fit around my shot grouping? I need to analyse it with image software rather than using my own interpretation, so if I could find a method that accounts for 95%> of my spread pattern and then fits a circle of best fit to it then that'd be perfect :)

Could anyone tell me how to do this please?



--
View this message in context: http://imagej.1557.x6.nabble.com/How-to-analyse-a-pattern-of-holes-tp5013892.html
Sent from the ImageJ mailing list archive at Nabble.com.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: How to analyse a pattern of holes?

BillyWu
Hi Dr. Straatman,

Thanks for getting back to me. I'm a total novice with ImageJ and I have never used it before. I've just ran your macro and it seems to be a good starting point. However I'm not totally sure what you mean by 'The value -25 depends on the size of your image and how accurate the measurement has to be. You could do this till the value is < 95% and then enlarge with smaller numbers till the value has become >95% again'.

I've got the dimensions of the paper I used so I'll be inputting those. What should I do with the -25 value? Increase or decrease if the circle is significantly different from the shot pattern?

Best regards,

Bill
Reply | Threaded
Open this post in threaded view
|

Re: How to analyse a pattern of holes?

Krs5
Dear Bill,

The -25 will be pixels on a non-scaled image. On a scaled image it depends what your scaling is. So basically it is how much smaller we make the ROI before the next measurement. I assume that your shot pattern is centred in your image. Maybe you could send a link to an sample image?

BW

Kees

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of BillyWu
Sent: 05 August 2015 12:08
To: [hidden email]
Subject: Re: How to analyse a pattern of holes?

Hi Dr. Straatman,

Thanks for getting back to me. I'm a total novice with ImageJ and I have never used it before. I've just ran your macro and it seems to be a good starting point. However I'm not totally sure what you mean by 'The value -25 depends on the size of your image and how accurate the measurement has to be. You could do this till the value is < 95% and then enlarge with smaller numbers till the value has become >95% again'.

I've got the dimensions of the paper I used so I'll be inputting those. What should I do with the -25 value? Increase or decrease if the circle is significantly different from the shot pattern?

Best regards,

Bill



--
View this message in context: http://imagej.1557.x6.nabble.com/How-to-analyse-a-pattern-of-holes-tp5013892p5013903.html
Sent from the ImageJ mailing list archive at Nabble.com.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: How to analyse a pattern of holes?

BillyWu
Dr. Straatman,

Here is a link to one of my image samples. http://i367.photobucket.com/albums/oo113/Vanguaard/test%204%20A1_zpsq0vzyaqt.jpg

Best regards,


Bill
Reply | Threaded
Open this post in threaded view
|

Re: How to analyse a pattern of holes?

Krs5
Dear Bill.

I have put some code together but at the moment the burned etches of the hole is causing still some problems. The code is not optimized yet and nothing is done with the result but it gives you an idea what could be done.  Try it on some of your images and see if it works or what the problems are.

----------------------------------------- code --------------------------------------------
title = getTitle();
title2 = File.nameWithoutExtension();
run("Duplicate...", " ");
run("Mean...", "radius=20");
imageCalculator("Subtract create 32-bit", title, title2+"-1.jpg");
run("8-bit");
run("Subtract Background...", "rolling=50 light");
setAutoThreshold("RenyiEntropy");
//setThreshold(0, 169);
run("Convert to Mask");
run("Analyze Particles...", "size=50-Infinity circularity=0.00-1.00 add");
setForegroundColor(0, 0, 0);
roiManager("Fill");
roiManager("Delete");
run("Analyze Particles...", "size=2-50 circularity=0.00-1.00 add");
roiManager("Deselect");
roiManager("OR");
roiManager("Delete");
roiManager("Add");
roiManager("Select", 0);
getStatistics(area); print("areaAll = "+area);
areaAll = area;
run("To Bounding Box");
run("Fit Circle");
roiManager("Delete");
run("Analyze Particles...", "add");
roiManager("Deselect");
roiManager("OR");
getStatistics(area); print("areaCircle = "+area);
areaCircle = area;
while (areaCircle/areaAll > 0.95){
 
r = areaCircle/areaAll;
print(r);
 run("Restore Selection");
 roiManager("Deselect");
 roiManager("Delete");
 run("Enlarge...", "enlarge=-25");
 run("Analyze Particles...", "add");
 roiManager("Deselect");
 roiManager("OR");
 getStatistics(area);print(area);
 areaCircle = area;
}
while (areaCircle/areaAll < 0.95){
r = areaCircle/areaAll;
print(r);
 run("Restore Selection");
 roiManager("Deselect");
 roiManager("Delete");
 run("Enlarge...", "enlarge=1");
 run("Analyze Particles...", "add");
 roiManager("Deselect");
 roiManager("OR");
 getStatistics(area);print(area);
 areaCircle = area;
}
r = areaCircle/areaAll;
print(r);
run("Restore Selection");
roiManager("Deselect");
roiManager("Delete");
roiManager("Add");
selectWindow(title);
roiManager("Select", 0);

----------------------- end code ----------------------------

This all can get speeded up and looped to open images automatically

Best wishes

Kees

Dr Ir K.R. Straatman
Senior Experimental Officer
Advanced Imaging Facility
Centre for Core Biotechnology Services
University of Leicester
http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif

________________________________________
From: ImageJ Interest Group [[hidden email]] on behalf of BillyWu [[hidden email]]
Sent: 05 August 2015 16:18
To: [hidden email]
Subject: Re: How to analyse a pattern of holes?

Dr. Straatman,

Here is a link to one of my image samples.
http://i367.photobucket.com/albums/oo113/Vanguaard/test%204%20A1_zpsq0vzyaqt.jpg

Best regards,


Bill



--
View this message in context: http://imagej.1557.x6.nabble.com/How-to-analyse-a-pattern-of-holes-tp5013892p5013908.html
Sent from the ImageJ mailing list archive at Nabble.com.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: How to analyse a pattern of holes?

BillyWu
Dr. Straatman,

Thank you for getting back to me with the macro. I get an error message when I attempt to use it though, I'm not totally sure why.

Instead of having the software automatically find the pellet holes and draw a circle of best fit, would it be possible to draw a circle of best fit if I pre-defined the pellet holes? The work I am doing is based off of a previous student's work from my university. This is an extract from their thesis that explains what they did, but not how they did it. I need to replicate this in the same way.

"To obtain a measurement of pellet dispersion the images were analysed using ImageJ
software. The pellet holes that comprised the perimeter of dispersion were selected
(excluding ‘fliers’; pellets significantly outside the general area of dispersion). The
software was then implemented to analyse the selected points and draw a circle of bestfit,
with >90% of the total number of pellets included within the circle. The software was
then used to provide an area measurement of the circle in mm2, with input of the known
dimensions of the paper for scale"


If you know how I could go about doing what they did then I would very much appreciate help in doing it.


Best regards,


Bill
Reply | Threaded
Open this post in threaded view
|

Re: How to analyse a pattern of holes?

BillyWu
I also have a bit of a problem with measuring my ellipse areas. What I do is I draw a line that fits the width of the paper and set the scale. For example, the paper is 507mm wide. After setting the scale, I then draw an ellipse on my shot pattern and use the measure tool. The problem is that I get an area that's way higher than it should be. I've done the measurements by hand originally and worked out the areas and diameters that way, but the results I get in ImageJ are much higher than they should be. Any advice please? Am I doing something wrong?
Reply | Threaded
Open this post in threaded view
|

Re: How to analyse a pattern of holes?

Krs5
In reply to this post by BillyWu
Dear Bill,

What is the error message?

Do you mean you want to manually select the pellet holes that you want to include in the circle and exclude the once you don't want? Is this allowed for the analysis?



----I also have a bit of a problem with measuring my ellipse areas. What I do is I draw a line that fits the width of the paper and set the scale. For example, the paper is 507mm wide. After setting the scale, I then draw an ellipse on my shot pattern and use the measure tool. The problem is that I get an area that's way higher than it should be. I've done the measurements by hand originally and worked out the areas and diameters that way, but the results I get in ImageJ are much higher than they should be. Any advice please? Am I doing something wrong? ------

If you have scaled the image and draw an ellipse you can select under Analyze > Set Measurements  'Area' and that should give you the area of your ROI. A quick check using A=πr2 show if/that it is correct. On the image you send I cannot see the edges of the paper. Are you sure the whole 507mm is in the image?

Best wishes

Kees

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of BillyWu
Sent: 07 August 2015 17:49
To: [hidden email]
Subject: Re: How to analyse a pattern of holes?

Dr. Straatman,

Thank you for getting back to me with the macro. I get an error message when I attempt to use it though, I'm not totally sure why.

Instead of having the software automatically find the pellet holes and draw a circle of best fit, would it be possible to draw a circle of best fit if I pre-defined the pellet holes? The work I am doing is based off of a previous student's work from my university. This is an extract from their thesis that explains what they did, but not how they did it. I need to replicate this in the same way.

/"To obtain a measurement of pellet dispersion the images were analysed using ImageJ software. The pellet holes that comprised the perimeter of dispersion were selected (excluding ‘fliers’; pellets significantly outside the general area of dispersion). The software was then implemented to analyse the selected points and draw a circle of bestfit, with >90% of the total number of pellets included within the circle. The software was then used to provide an area measurement of the circle in mm2, with input of the known dimensions of the paper for scale"/

If you know how I could go about doing what they did then I would very much appreciate help in doing it.


Best regards,


Bill



--
View this message in context: http://imagej.1557.x6.nabble.com/How-to-analyse-a-pattern-of-holes-tp5013892p5013953.html
Sent from the ImageJ mailing list archive at Nabble.com.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: How to analyse a pattern of holes?

BillyWu
The error message is as follows;

"Image not found in line 5.

imageCalculator ("Subtract create 32-bit" , title , title2 + <"-1.jpg"> ) ;"


Yes, I want to include the holes I want in the circle and exclude the others. The others are ones that are significantly outside of the dispersion area and are counted as 'flyers'; shot pellets that are significantly off-course and not an accurate representation of the shot pattern.

Yes, the paper in the image is 507mm. The image has been cropped from it's original size to exclude the black background I used to photograph my samples over.
Reply | Threaded
Open this post in threaded view
|

Re: How to analyse a pattern of holes?

Krs5
Dear Bill,

Is it possible that your original files are not jpg files? The test file is a jpg and the code works on it. If it is something else you have to change the 'jpg' part of this code.

You could use the find maxima option (Process > Find Maxima... ) with a tolerance of 25, output 'Single Points' and 'Light background' selected. After OK you can draw your own ROI, clear everything outside the ROI (Edit > Clear Outside; take care that background colour is black) and use the macro code from line 16: run("Analyze Particles...", "size=2-50 circularity=0.00-1.00 add"); only change the 2-50 to 1-50.

If you use the recorder (Plugins > Macros > Record) you can collect code to change the start of the macro.

Hope this makes sense.

Best wishes

Kees

________________________________________
From: ImageJ Interest Group [[hidden email]] on behalf of BillyWu [[hidden email]]
Sent: 10 August 2015 13:17
To: [hidden email]
Subject: Re: How to analyse a pattern of holes?

The error message is as follows;

"Image not found in line 5.

imageCalculator ("Subtract create 32-bit" , title , title2 + <"-1.jpg"> ) ;"


Yes, I want to include the holes I want in the circle and exclude the
others. The others are ones that are significantly outside of the dispersion
area and are counted as 'flyers'; shot pellets that are significantly
off-course and not an accurate representation of the shot pattern.

Yes, the paper in the image is 507mm. The image has been cropped from it's
original size to exclude the black background I used to photograph my
samples over.



--
View this message in context: http://imagej.1557.x6.nabble.com/How-to-analyse-a-pattern-of-holes-tp5013892p5013965.html
Sent from the ImageJ mailing list archive at Nabble.com.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: How to analyse a pattern of holes?

BillyWu
Dear Dr. Straatman,

Thank you for your assistance up until this point. I haven't had much opportunity to test the macro out properly as my thesis is due very soon. However, I would like to add you to my acknowledgements section for the assistance you've provided. I'd also like to include your macro in the appendix, so that whoever takes up my research next will be able to use it, tweak and evaluate it's effectiveness over the typical 'select spread perimeter holes, apply circle of best fit' method.

Would this be okay?

Best regards,

Bill
Reply | Threaded
Open this post in threaded view
|

Re: How to analyse a pattern of holes?

Krs5
Dear Bill,

That is OK with me. The code is also available on the mailing list.

Best wishes

Kees

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of BillyWu
Sent: 20 August 2015 13:09
To: [hidden email]
Subject: Re: How to analyse a pattern of holes?

Dear Dr. Straatman,

Thank you for your assistance up until this point. I haven't had much opportunity to test the macro out properly as my thesis is due very soon.
However, I would like to add you to my acknowledgements section for the assistance you've provided. I'd also like to include your macro in the appendix, so that whoever takes up my research next will be able to use it, tweak and evaluate it's effectiveness over the typical 'select spread perimeter holes, apply circle of best fit' method.

Would this be okay?

Best regards,

Bill



--
View this message in context: http://imagej.1557.x6.nabble.com/How-to-analyse-a-pattern-of-holes-tp5013892p5014074.html
Sent from the ImageJ mailing list archive at Nabble.com.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html