Dr. Cho’s Website
Course Materials

# Logic and arithmetic image operations

Institute for Environmental and Spatial Analysis
University of North Georgia

## 1   Bitwise logic operations

Mainly used for masking (selecting features to enhance)

### 1.1   NOT

$f(x,y)$NOT
01
10

### 1.2   AND

AND01
000
101
• $f$ AND 0xff?
• NOT ($f$ AND 0xff)?

OR01
001
111

XOR01
001
110

## 2   Exercise: Shadow enhancement using logic operations

1. Log the map: log_map
• Brighten everywhere, not just the shadow
2. Gray-level binary slice the map: mask_shadow
• Identify the range of pixel values
• 255 for the shadow, 0 for the rest
• What range works best?
3. log_map AND mask_shadow: enhanced_shadow
4. NOT mask_shadow: mask_nonshadow
5. map AND mask_nonshadow: nonenhanced_nonshadow
6. nonenhanced_nonshadow OR enhanced_shadow: map_with_enhanced_shadow

## 3   Arithmetic operations

### 3.1   Subtraction

Difference/motion detection

$g(x,y)=f(x,y)-h(x,y)$

### 3.2   Averaging

Let $f(x,y)$ be a noiseless image, but we have $g(x,y)=f(x,y)+\eta(x,y)$ where $\eta(x,y)$ is noise with a zero mean. For example, $\eta\sim\mathcal{N}(0,\sigma_\eta^2)$.

How can we enhance $g(x,y)$ and make it closer to $f(x,y)$?

### 3.3   Averaging: Need more noisy images?

Obtain more noisy images $g_i(x,y)$ for $1\leq i\leq K$.

### 3.4   Averaging: Take the average of these images

The average of these noisy images \begin{split} \bar{g}(x,y)&=\frac{1}{K}\sum_{i=1}^K g_i(x,y)\\ &=f(x,y)+\frac{1}{K}\sum_{i=1}^K\eta_i(x,y). \end{split}

### 3.5   Average: The expected value of the average

The expected value of $\bar{g}(x,y)$ $E\left[\bar{g}(x,y)\right]=f(x,y)$ because $f(x,y)$ is constant and $E\left[\frac{1}{K}\sum_{i=1}^K\eta_i(x,y)\right]=0$.

More important, $\sigma_{\bar{g}(x,y)}=\frac{1}{\sqrt{K}}\sigma_\eta(x,y),$ which means the more $g_i(x,y)$, the smaller error.

## 4   Exercise: Noise reduction using averaging

1. Add noise to the map: noisy_map_1
• Probability of noise: 0.5
• Max noise: 20
2. Repeat step 1 * 4 more times: noisy_map_2, ..., noisy_map_5
3. Subtract the map from noisy_map_1: diff_1
4. Average noisy_map_1 and noisy_map_2: average_map_2
5. Subtract the map from average_map_2: diff_2
6. Repeat steps 4-5 * 3 more times by adding one more noisy map each time
7. Compare the histograms of diff_1, ..., diff_5

## 5   Homework 4

Find how many noisy maps you need to reduce the standard deviation of noise below 10% of its maximum (you decide this number when adding noise)? Submit your report and the original gray, noisy, and difference maps in TIFF in one ZIP file to D2L. In the report, explain how you calculated the noisy and difference maps, mention your maximum noise, and add a table with the number of noisy maps for averaging, the average and standard deviation of the difference map for each averaging. For example,

Number of noisy mapsAverage noiseSD noiseSD/max noise (%)
10.1710.552.5%
20.255.527.5%
...
100.151.57.5%