Logic and arithmetic image operations

Dr. Huidae Cho
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

1.2   AND

  • $f$ AND 0xff?
  • NOT ($f$ AND 0xff)?

1.3   OR


1.4   XOR


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


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: Non-shadow enhancing

Using a new workflow that is very similar to the shadow-enhancing technique we used in class, enhance non-shadow areas in your original grayscale image because these areas are too bright. Capture the original image, step-by-step tool screenshots, and the final image. For each step, explain why you use which specific tool.

6   Homework: Noise reduction using averaging

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 (%)