Skip to content

Commit 044ee4c

Browse files
committed
adds DifferenceOfGaussian_withWatershed.ijm to Week-05
1 parent c9926e8 commit 044ee4c

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

Diff for: Week-05/DifferenceOfGaussian_withWatershed.ijm

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* Difference of Gaussian & Watershed
3+
* ----------------------------------------------
4+
*
5+
* This short macro showcases use of Difference of Gaussian combined with watershed
6+
*
7+
* Due to the simple nature of this code, no copyright is applicable
8+
*
9+
* Code created for Image Processing and Analysis For Life Scientists MOOC on EdX
10+
* https://www.edx.org/course/image-processing-and-analysis-for-life-scientists
11+
*
12+
* 2019 - Romain Guiet, EPFL - SV - BIOP
13+
* https://biop.epfl.ch
14+
*/
15+
16+
close("\\Others");
17+
roiManager("reset");
18+
19+
// you need to open an image first.
20+
// like thet homogeneous_beads.tif or heterogeneous_beads.tif
21+
// iamges can be downloaded at :
22+
// https://drive.google.com/a/epfl.ch/file/d/1hdBO-z6GxYRv-E9AXY1NUv3cnjM1h-3W/view?usp=sharing
23+
beads_image = getTitle()
24+
25+
// we define here a sigma for a Gaussian Blur
26+
sigma1 = 1 ;
27+
// and we calculate a 2nd sigma, by multipling sigma by a given factor.
28+
// (in this exemple it's 1.6 but it could be different)
29+
sigma2 = 1.6 * sigma1 ;
30+
31+
// select the image, duplicate and apply a Gaussian Blur with the defined Sigma
32+
selectImage(beads_image);
33+
run("Duplicate...", "title=gb"+sigma1);
34+
run("Gaussian Blur...", "sigma="+sigma1);
35+
//
36+
selectImage(beads_image);
37+
run("Duplicate...", "title=gb"+sigma2);
38+
run("Gaussian Blur...", "sigma="+sigma2);
39+
40+
// Calcultate an image by substrating the smallest to the largest sigma
41+
imageCalculator("Subtract create 32-bit", "gb"+sigma2,"gb"+sigma1);
42+
selectImage(nImages);
43+
rename("Difference of Gaussian");
44+
45+
// Thresholding
46+
setAutoThreshold("Triangle no-reset");
47+
run("Convert to Mask");
48+
49+
// Use the Watershed
50+
run("Watershed");
51+
52+
// Detect Particles
53+
run("Analyze Particles...", "size=20-Infinity pixel summarize add");

0 commit comments

Comments
 (0)