Java Notes | ||
Absolute value | y = |x| | y = Math.abs(x); |
Power elevation | y = xa | y = Math.pow(x, a); |
Exponential functions | y = ea | y = Math.exp(a) |
Number Pi | π | double pi = Math.PI; |
Closest integer of x | int y = (int)Math.round(x); | |
Largest integer of x | int y = (int)Math.ceil(x); |
1. Implementation of the 3x3 moving-average filter
The 3x3 moving-average filter replaces a pixel by its average in a 3x3 centered window. There are several ways to implement a moving-average filter. We provide three versions of the implementation and one version is :Read and understand the code of two plugin versions of the moving average filter in Code.java
Apply the three routines on the stack of images "cell-zstack.tif" and compare the results of the three versions in terms of time computation and image content. Fill in the report.
2. Implementation of filters
Implements the filters below. If it is a separable filter, implement it in a separable way, while taking proper care of the boundaries (mirror conditions).
2.1 Filter A
Write a method doFilterA() that implements the filter defined by the following mask. |
2.2 Filter B
Write a method doFilterB() that implements the filter defined by the following mask. |
2.3 Filter C
Write a method doFilterC() that implements the filter defined by the following mask. |
2.4 Filter D: Southeast shadows filter
Write a method doFilterD() that produces a Southeast shadows effect on an image. |
3. Detection of spots
Here, we propose to detect the brightest cities (bright spots) on a part of the world image "earth.tif" provided by a satelitte. Convert this image in grayscale image (menu Image→Type→8-bit).a. Gaussian filter
First, we have to implement the 2D Gaussian filter hσ where the standard deviation σ controlles the smoothing strength. We propose to discretize the 2D Gaussian function between [-3*σ,3*σ].
To simplify the implementation, we choose a size of the filter equal to n = (int)(2*ceil(3*σ))+1, hence n is always odd.
Write a method doGaussian() that convolves an image with this Gaussian filter as non-separable or separable way.
Check the Gaussian filter using Gaussian plugin.
b. Difference of Gaussian
Write a method doDoG() that implements the DoG by calling two times the Gaussian filter and making the substraction. We choose σ2 = 2 . σ1. Check the DoG filter using DoG plugin.
c. Application to the spot detection
Apply the DoG filter and the threshold T (menu Image→Adjust→Threshold).
Find the parameters σ1 and T to detect the brightest cities (around 50 ±20 cities) in the pictureand fill the report.