How to Exclude an Area?

I’m working on a forensic science project. I am attempting to count the number of gunshot residue (GSR) particles on a paper target. I want to exclude the bullet hole in the center of the GSR particles which surround the bullet hole.

Is there an easy way to eliminate (exclude) the bullet hole from the counting analysis?
Here is a sample image:
[https://www.dropbox.com/s/8rwaqziirwciija/BEFORE%20HOAc_cr.jpg?dl=0]

Thanks.

Dear Alex,
I assume that you threshold the image and then use the ‘Analyze Particle’ function. In that case you should be able to exclude the bullet hole by simply setting appropriate size limits in the Analyze Particle function. Alternatively, just exclude the particle with the largest area (or diameter) from the list of measurements.
Hope this answers your question,
Volko

Dear Volko,
Yes, I do the threshold and the analyze particle function but the problem is that the bullet hole is ragged, irregular and some of the edges get mistakenly counted as particles. I would prefer to be able to draw a circle around the hole that would exclude it completely.

Thank you,

Alex

Hi
@AlexJ
If this result is your goal then use the plug-in:
1.RGB —> CMYK

  1. Stack to images
  2. Select K
    4.Minimum threshold
    Please tell me if this is OK.
    Thank you in advance

20200730_Medecine legale-1

Hi Mathew,

I have not tried your suggested technique but I do not think it will work. I want to eliminate the entire circle area. The dark margins are from bullet wipe, not gunshot residue particles. (You can see that some of the irregular areas in the dark margin are mistakenly counted as particles). I need to be able to draw an exclusion circle around the outside of bullet hole dark area.

Thank you for your suggestion,

Alex

Read this:

If you can manually draw an exclusion circle then there might be a simple solution.:
Draw the exclusion circle in the thresholded image and simply fill this region with the background color (white) to exclude the region from particle detection.

If it is a problem to draw the circle in the thresholded image you can use a copy of the original, draw the exclusion circle in the copy and use ‘Restore Selection’ to transfer the selection to the thresholded image.

If you want to automate the process you can in a first step detect the bullet hole, fit a circular Roi to this object and increase the radius. This increase Roi can be used to clean the region after thresholding.

1 Like

Phaub,

Thanks for your suggestion. I did draw a circle, filled it with white and it seemed okay. But the particle analysis was performed, the image showed that “particles” were found inside the filled-in white area. This doesn’t appear to make sense. Here is an image showing the before and after analysis. Where did those mystery particles come from? I also don’t like the margins of the “after” hole – very ragged and poorly defined.

Note: I did another test in which I used CorelDraw to create a white “patch” over the hole. That method did work: The particle analyzed image showed no particles inside the white patch.

Hi
@AlexJ

You want to remove the central part on your image. Test this.

macro "Forensic science"
{
requires("1.53b");
setBackgroundColor(0,0,0);
setOption("BlackBackground",true);
//---------------------------
// Start batch mode
setBatchMode(true);

//-----------------------------
//Copy and select
img=getImageID();
selectImage(img);
run("Duplicate...", "title=1 ");
close("\\Others");
run("Duplicate...", "title=2 ");
run("RGB to CMYK");
selectWindow("CMYK_2");
run("Stack to Images");
selectWindow("K");
//setTool("wand");
doWand(1196, 1384, 0.44, "Legacy");
roiManager("Add");
//roiManager("Show All");
roiManager("Select", 0);
run("Fit Circle");
roiManager("Add");
roiManager("Select", 1);
run("Enlarge...", "enlarge=3");
roiManager("Add");
selectWindow("1");
roiManager("Select", 0);
setBackgroundColor(255, 255, 255);
run("Clear", "slice");
roiManager("Select", 2);
run("Clear", "slice");
roiManager("Show None");
run("Select None");
// End of processing
//----------------------------
// End of batch mode
setBatchMode(false);
//setTool("zoom");
run("Set... ", "zoom=400 x=1195 y=1380");
run("Tile");
//--------------------------------
exit("All is done !");
}

Additional treatment:

run("8-bit");
setAutoThreshold("Intermodes");
//run("Threshold...");
//setThreshold(0, 112);
setOption("BlackBackground", true);
run("Convert to Mask");
run("Analyze Particles...", "display clear add");

We get this:

Have a good day

1 Like

Dear Mathew,

I’m excited to try your macro. I originally got an error message (Line 17) but I realized that I was missing the “RGB to CMYK” plugin. I found it and installed it.

Your method really works well to eliminate the hole!

Note: I am using 1.53c – does that matter?

I manually worked the steps in your “Additional Treatment” but that did not work so well. I only got a count of 10 particles. I adjusted the threshold (using “intermode”) but did not use “Dark Background” = threshold of 0-32 – and then I got a more realistic particle count of 2,208.

UPDATE: I used your macro on a different image (with the bullet hole in a different location) and it did not work to eliminate the hole. After a while I realized that the macro you wrote will only work with an image that has the hole in the same exact location. I need to be able to do the hole-exclusion on many other images – so it appears that the best method for me is to manually cover the hole and then bring the image into ImageJ.

But I am very grateful for your help. I’ve learned much from this.

Thank you,
Alex

1 Like
  • Open an open
  • Convert it to 8-bit
  • Adjust the threshold (BlackBackground=OFF)
  • APPLY the adjusted threshold
    (Now you should have binary image)
  • Draw a circle
  • Use FILL or CLEAR (depending on your current Forground/Background Color) to ‘delete’ the area inside the circle
  • Perform ParticleAnalysis

This works perfect in my tests.

One note on @Mathew script. As I wrote, a first step would be to detect the bullet hole.

Instead of assuming this hole in a defined position in the image you can mark the hole by drawing a Point selection. This position can be used as starting point for the doWand() command in the macro.

1 Like

Phaub,

Thanks for your suggestion. I’m going to compare it with bringing in a already “fixed” image from PS.

Thanks,
Alex