Chpater 3PDF - 1
Chpater 3PDF - 1
1 Give a single intensity transformation function for spreading the intensities of an image so the
lowest intensity is 0 and the highest is L − 1.
3.2 Do the following: 3.3 Do the following:(a) * Propose a set of intensity-slicing transforma-tion functions capable of producing all
(a) * Give a continuous function for implement- ing the contrast stretching transformation in Fig. 3.2(a). In theindividual bit planes of an 8-bit monochromeimage. For example, applying to an image atransformation
addition to m, your function must include a parameter, E, for control- ling the slope of the function as it transi- function with the propertyTr()= 0 if r is 0 or even, and Tr()= 1 if r isodd, produces an image of the least signifi-
tions from low to high intensity values. Your function should be normalized so that its minimum and maximum cant bit plane (see Fig. 3.13). (Hint: Use an8-bit truth table to determine the form ofeach transformation
values are 0 and 1, respectively. (b) Sketch a family of transformations as a function of parameter E, for a fixed function.)(b) How many intensity transformation functionswould there be for 16-bit images?(c) Is the basic
value m= L2, where L is the number of intensity levels in the image.. approach in (a) limited to imagesin which the number of intensity levels is aninteger power of 2, or is the method
generalfor any number of integer intensity levels?(d) If the method is general, how would it be dif-ferent from
your solution in (a)?
3.4 Do the following:
(a) Propose a method for extracting the bit planes of an image by converting the pixel values to binary.
(b) Find all the bit planes of the following 4-bit image: {0,1,8,6},{2,2,1,1},{1,15,14,12},{3,6,9,10}\{0, 1, 8, 6\}, \{2, 2,
1, 1\}, \{1, 15, 14, 12\}, \{3, 6, 9, 10\}{0,1,8,6},{2,2,1,1},{1,15,14,12},{3,6,9,10}
(a) Method for Extracting Bit Planes by Converting Pixel Values to Binary
To extract the bit planes of an image by converting the pixel values to binary, follow these steps:
1. Convert Pixel Values to Binary: For each pixel in the image, convert its decimal value to an 8-bit binary
representation (or the appropriate number of bits based on the image depth).
2. Initialize Bit Planes: Create an array or matrix for each bit plane. For an 8-bit image, you would create 8
matrices (one for each bit plane).
3. Populate Bit Planes: For each pixel in the image:
o Extract the binary representation.
o For each bit position (from least significant bit to most significant bit), assign the value of that bit to the 20. {0, 1, 0, 0}
corresponding bit plane matrix. If the bit is 1, set the corresponding position in the bit plane matrix to 21. }
1; if the bit is 0, set it to 0. 22. Bit Plane 4 (Most Significant Bit):
4. Output Bit Planes: After processing all pixels, you will have a set of matrices, each representing a bit plane of o Values: 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1
the original image. o Matrix:
(b) Finding All Bit Planes of the Given 4-bit Image 23. {
Given the 4-bit image represented as: 24. {0, 0, 1, 0},
{ 25. {0, 0, 0, 0},
{0, 1, 8, 6}, 26. {0, 1, 1, 1},
{2, 2, 1, 1}, 27. {0, 1, 1, 1}
{1, 15, 14, 12}, 28. }
{3, 6, 9, 10} Summary of Bit Planes
} • Bit Plane 1:
First, we convert each pixel value to its 4-bit binary representation: {
• 0 → 0000 {0, 1, 0, 0},
• 1 → 0001 {0, 0, 1, 1},
• 8 → 1000 {1, 1, 0, 0},
• 6 → 0110 {1, 0, 1, 0}
• 2 → 0010 }
• 2 → 0010 • Bit Plane 2:
• 1 → 0001 {
• 1 → 0001 {0, 0, 0, 1},
• 1 → 0001 {0, 0, 0, 0},
• 15 → 1111 {0, 1, 1, 1},
• 14 → 1110 {1, 1, 0, 1}
• 12 → 1100 }
• 3 → 0011 • Bit Plane 3:
• 6 → 0110 {
• 9 → 1001 {0, 0, 1, 0},
• 10 → 1010 {0, 0, 0, 0},
Now, we can extract the bit planes: {0, 1, 1, 1},
1. Bit Plane 1 (Least Significant Bit): {0, 1, 0, 0}
o Values: 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0 }
o Matrix: • Bit Plane 4:
2. { {
3. {0, 1, 0, 0}, {0, 0, 1, 0},
4. {0, 0, 1, 1}, {0, 0, 0, 0},
5. {1, 1, 0, 0}, {0, 1, 1, 1},
6. {1, 0, 1, 0} {0, 1, 1, 1}
7. } }
8. Bit Plane 2:
o Values: 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1 3.5 In general: (a) * What effect would setting to zero the lower order bit planes have on the histogram of an
o Matrix: image? (b) What would be the effect on the histogram if we set to zero the higher-order bit planes instead?
9. { 3.5 (a) Effect of Setting Lower Order Bit Planes to Zero on the Histogram
10. {0, 0, 0, 1}, Setting the lower order bit planes (e.g., the least significant bits) of an image to zero effectively reduces the detail and
11. {0, 0, 0, 0}, subtle variations in intensity levels. The lower order bits contribute to the finer details of the image, such as slight
12. {0, 1, 1, 1}, changes in shading and texture.
13. {1, 1, 0, 1} Effect on Histogram:
14. } • Reduced Variability: The histogram will show a reduction in the number of distinct intensity levels. Since the
15. Bit Plane 3: lower order bits are responsible for the finer gradations, zeroing them will cause many pixel values to cluster
o Values: 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0 around fewer intensity levels.
o Matrix: • Bimodal or Trimodal Distribution: The histogram may become bimodal or trimodal, depending on the
16. { remaining significant bits, as the image will lose its subtle variations and may only represent a few dominant
17. {0, 0, 1, 0}, intensity values.
18. {0, 0, 0, 0}, • Loss of Detail: The overall appearance of the histogram will reflect a loss of detail, as the image will appear
19. {0, 1, 1, 1}, more uniform, leading to a flatter histogram with fewer peaks.
3.5 (b) Effect of Setting Higher Order Bit Planes to Zero on the Histogram
Setting the higher order bit planes (e.g., the most significant bits) to zero has a more drastic effect on the image's overall
appearance and the histogram.
Effect on Histogram:
• Significant Loss of Information: The higher order bits contain the most significant information about the
image, including the overall brightness and major features. Zeroing these bits will lead to a significant loss of
information.
• Clustering at Low Intensity Levels: The histogram will likely show a clustering of pixel values at lower
intensity levels, as the higher order bits are responsible for representing the brighter parts of the image. This can
result in a histogram that is heavily skewed towards the lower end of the intensity range.
• Flat Histogram: The histogram may become very flat, indicating that most of the pixel values are concentrated
in a narrow range, often resulting in a loss of contrast and detail in the image.
In summary, setting lower order bit planes to zero reduces detail and variability in the histogram, while setting higher
order bit planes to zero leads to a significant loss of information and a clustering of pixel values at lower intensity levels,
resulting in a flatter histogram.
3.6 Explain why the discrete histogram equalization technique does not generally yield a flat histogram.
Discrete histogram equalization is a widely used image enhancement technique that adjusts the contrast of an image by
redistributing its intensity values. While it aims to produce a uniform distribution of intensities, there are several reasons
why it may not yield a perfectly flat histogram:
1. Non-uniform Input Distribution: If the input image has a highly non-uniform intensity distribution, histogram
equalization may redistribute pixel intensities but not necessarily achieve a flat histogram. For example, if a
significant number of pixels are concentrated in a specific intensity range, the equalization process will stretch
those values while potentially leaving others underrepresented.
2. Limited Dynamic Range: Histogram equalization works best when there is a wide dynamic range of intensity
values available in the image. If the image already has a limited range of values (e.g., many pixels are close to
black or white), the resulting histogram after equalization may not flatten out as intended.
3. Presence of Noise: Noise in the image can affect the histogram. If there are noise peaks in certain intensity
levels, equalization may enhance these peaks instead of distributing values uniformly across the histogram,
leading to a histogram that retains peaks corresponding to the noise.
4. Interpolation Effects: Histogram equalization often involves interpolation between intensity levels,
particularly when mapping pixel values from the original histogram to the equalized histogram. This can lead
to artifacts and prevent a perfectly flat distribution.
5. Loss of Information: The process can lead to a loss of detail in certain areas of the image if many intensity
values are combined into the same new intensity level, which can cause uneven distribution and prevent the
histogram from flattening completely.
6. Quantization Errors: If the image is represented with a limited number of bits (e.g., an 8-bit image),
quantization can lead to certain intensity levels being represented more frequently, thus not achieving a flat
histogram after equalization.
3.7 Suppose that a digital image is subjected to histogram equalization. Show that a second pass of histogram
equalization (on the histogram-equalized image) will produce exactly the same result as the first pass.
Conclusion
In essence, the transformation of intensity levels during histogram equalization ensures that, after the first pass, the pixel
intensities are already distributed uniformly across the intensity range. Thus, applying the same process again does not
change the distribution any further.
Therefore, we can conclude that a second pass of histogram equalization on an already histogram-equalized image will
yield the same result as the first pass. The output image I′′I''I′′ will be identical to the first equalized image I′I'I′:
I′′=I′I'' = I'I′′=I′
3.8 Assuming continuous values, demonstrate with an example that it is possible for the transformation function
given in Eq. (3-11) to satisfy conditions (a) and (b) discussed in Section 3.3, while its inverse may fail to satisfy
condition (a).
this.
3.12 An image with intensities in the range [,] 01 has the PDF, prr (), shown in the following figure. It is desired
to transform the intensity levels of this image so that they will have the specified pzz () shown in the figure.
a symmetry about the line joining the endpoints (0,0) and (L-1,L-1), where L is the maximum
intensity level.
3. Mathematical Justification:
a. If Gz (q) is a monotonically increasing function that maps the input intensities to output intensities,
then its inverse Gs−1 (k) will also be monotonically increasing. The relationship can be expressed
mathematically as: Gs−1 (Gz (q))=q
b. This relationship implies that for every intensity level q in the output, there is a corresponding
intensity level k in the input that reflects this symmetry.
4. Conditions for the Property to Hold:
a. The property holds true as long as the transformation functions are continuous and monotonic. If
the transformation functions are designed to be piecewise linear or have discontinuities, the mirror
image property may not hold.
3.14 The local histogram processing method discussed in Section 3.3 requires that a histogram be computed at each
neighborhood location. Propose a method for updating the histogram from one neighborhood to the next, rather
than computing a new histogram each time.
To efficiently update the histogram from one neighborhood to the next in local histogram processing, you can use
a method that leverages the overlap between consecutive neighborhoods. This approach avoids the need to
recompute the entire histogram from scratch for each new neighborhood location. Here’s a step-by-step outline
of the proposed method:
Method for Updating the Histogram
1. Define the Neighborhood Size:
a. Let the neighborhood size be N×N (for example, 3×3). This means that each neighborhood consists
of N2 pixels.
2. Initialize the Histogram:
a. Compute the initial histogram for the first neighborhood. This will serve as the starting point for
subsequent updates.
3. Sliding the Neighborhood:
a. As you move the center of the neighborhood from one pixel to the next, you will typically slide the
neighborhood either horizontally or vertically. For example, moving one pixel to the right means
that the leftmost column of the previous neighborhood will exit, and a new column will enter from
the right.
The property that the transformation function Gs−1 (k) (labeled as (2) in Fig. 3.25(b)) is the mirror image of Gz (q)
4. Update the Histogram:
(labeled as (1)) about a line joining the two endpoints does indeed hold under certain conditions, specifically when
a. Remove the Exiting Pixels: For the pixel values that are leaving the neighborhood (the leftmost
the transformation functions are designed to achieve histogram specification.
column in the case of a rightward slide), decrement the count of these pixel values in the histogram.
Explanation b. Add the Entering Pixels: For the new pixel values that are entering the neighborhood (the new
rightmost column), increment the count of these pixel values in the histogram.
1. Transformation Functions:
5. Handle Edge Cases:
a. Gz (q) is the transformation function that maps the input intensity levels r to the output intensity
a. If the neighborhood is sliding vertically, apply the same logic: remove the pixel values from the top
levels z based on the specified histogram.
row and add the pixel values from the bottom row.
b. Gs−1 (k) is the inverse transformation function that maps the histogram-equalized intensity levels
b. Ensure that you handle the edges of the image properly, where the neighborhood may not be fully
s back to the output intensity levels z.
defined (e.g., at the borders of the image).
2. Mirror Image Property:
a. The mirror image property arises from the nature of histogram equalization and specification.
When you perform histogram equalization, you are essentially redistributing the intensity values
across the entire range, which can be visualized as stretching or compressing certain ranges of
intensity values.
b. The inverse function Gs−1 (k) effectively undoes this mapping, and due to the way the cumulative
distribution functions (CDFs) are constructed, the relationship between the two functions results in
• Update the
histogram:
o Remove the exiting pixel values (10, 20, 30 from the leftmost column):
▪ 10: 0
▪ 20: 1
▪ 30: 1
o Add the entering pixel values (30, 40, 50 from the new rightmost column):
▪ 30: 2
▪ 40: 2
▪ 50: 3
▪ 60: 2
• Updated histogram:
o 20: 1
o 30: 2
o 40: 2
o 50: 3
o 60: 2
• Conclusion
• By using this method of updating the histogram based on the pixels that exit and enter the neighborhood,
you can significantly reduce the computational cost associated with local histogram processing. This
approach allows for real-time processing and is particularly useful in applications where speed is critical,
such as in video processing or real-time image enhancement.
3.16 You are given a computer chip that is capable of performing linear filtering in real time, but you are not
informed whether the chip performs correlation or convolution. Describe a test you would perform to determine
which of the two operations the chip performs.
3.19 Prove the validity of Eqs. (3-36) and (3-37).
Given K, I-D Gaussian kernels, gt , g2 , ...,gK, with arbitrary means and standard deviations:
(a)* Determine what the entries in the third col- umn of Table 3.6 would be for the product 3.26 The two images shown in the following figure are quite different, but their histograms are the same. Suppose
gl xg2 that each image is blurred using a 33× box kernel. (a) * Would the histograms of the blurred images still be
(b) What would the fourth column look like for the convolution gt ? equal? Explain.
(Hint: It is easier to work with the variance; the standard deviation is just the square root of your
result.)
(b) If your answer is no, either sketch the two histograms or give two tables detailing the histogram components.
Part (a): Will the histograms of the blurred images still be equal?
Explanation:
The two images have different spatial structures (a vertical bar and a checkerboard pattern). Blurring with a 33×33 box
kernel averages pixel intensities over large areas, and this operation interacts differently with the distinct structures in
the images:
• In the vertical bar image, there will be a gradual transition from black to white, generating mostly grayscale
values along that transition.
• In the checkerboard image, the alternating black and white squares will blend into a more even distribution of
grayscale values across the image.
Thus, the blurring process will produce different distributions of pixel values in the two images, resulting in different
histograms.
Part (b): Sketch or give two tables detailing the histogram components.
1. Left Image (Vertical Bar): After blurring, the histogram will show two strong peaks (one near black, one near
white), with some intermediate gray values due to the smoothing at the edges of the bar.
a. Strong peaks at both ends (near 0 and 255).
b. Some distribution of gray values (mid-range intensities).
2. Right Image (Checkerboard): After blurring, the histogram will have a flatter distribution of pixel values, as
the checkerboard pattern blends into a range of grays.
a. A wider, more evenly distributed set of values across the grayscale range.
3.27 An image is filtered four times using a Gaussian kernel of size 3x3 with a standard deviation of 1.0. Because
of the associative property of con- volution, we know that equivalent results can be obtained using a single
Gaussian kernel formed by convolving the individual kernels. (a) * What is the size of the single Gaussian ker-
nel? (b) What is its standard deviation?
3.29 * Discuss the limiting effect of repeatedly filtering an image with a 3x3 lowpass filter kernel. You may ignore
border effects.
3.28 An image is filtered with three Gaussian lowpass kernels of sizes 3x3 , 5× 5, and 7× 7, and stan- dard Repeatedly filtering an image with a 3x3 lowpass filter kernel, such as a box or Gaussian filter, leads to a
deviations 1.5, 2, and 4, respectively. A composite filter, w, is formed as the convolution of these three filters. (a) phenomenon known as "blurring." Each application of the filter smooths the image by averaging the pixel values
* Is the resulting filter Gaussian? Explain. (b) What is its standard deviation? (c) What is its size? in the neighborhood defined by the kernel.
1. Loss of Detail: With each successive filtering, fine details and sharp edges in the image are progressively
smoothed out. This is because the averaging process tends to reduce the contrast between adjacent pixels,
leading to a loss of high-frequency information.
2. Convergence to Uniformity: As the filtering is applied multiple times, the image tends to converge
towards a more uniform appearance. This means that the variations in pixel intensity become less
pronounced, and the image may eventually appear as a blurred version of the original, losing its distinct
features.
3. Effect on Noise: While lowpass filtering can help reduce noise, excessive filtering can also lead to the loss
of important image features. The noise may be smoothed out, but so will the edges and textures that
define the objects in the image.
4. Mathematical Perspective: From a mathematical standpoint, each application of the filter can be viewed
as a convolution operation. Repeated convolution with the same kernel can be represented as a single
convolution with a larger kernel that approximates the effect of multiple applications. This results in a
kernel that has a wider spread, further enhancing the blurring effect.
3.30 In Fig. 3.42(b) the corners of the estimated shading pattern appear darker or lighter than their surrounding
areas. Explain the reason for this.
The phenomenon where the corners of an estimated shading pattern appear darker or lighter than their
surrounding areas can be attributed to several factors related to image processing and the effects of filtering,
particularly in the context of spatial filtering and edge effects.
Explanation
1. Edge Effects: When applying filters to an image, especially those that involve convolution, the edges of
the image can be affected differently than the central regions. This is because the filter kernel may not
have enough surrounding pixels to compute a proper average or sum of products at the corners. As a
result, the filtered values at the corners can be influenced more heavily by the limited number of
neighboring pixels, leading to artifacts such as darker or lighter corners.
2. Kernel Size and Shape: The size and shape of the kernel used for filtering can also contribute to this effect.
For instance, if a large kernel is used, the corners may not have enough data to provide a balanced output,
causing them to reflect the values of the few available pixels more strongly. This can create a noticeable
difference in intensity at the corners compared to the center of the image.
3. Gradient and Shading Estimation: In the context of shading patterns, if the estimated shading is based
on gradients or local intensity variations, corners may exhibit abrupt changes in intensity. This can happen
if the algorithm used to estimate shading does not account for the smooth transitions typically expected
in shading, leading to abrupt changes in pixel values at the corners.
4. Convolution Artifacts: When convolving an image with a kernel, especially if the kernel is not normalized
or if it sums to a value other than one, the resulting pixel values can be skewed. If the kernel emphasizes
certain directions or areas, it can lead to an overemphasis of light or dark areas at the corners.
5. Lighting Conditions: The original lighting conditions of the scene being imaged can also play a role. If the
corners of the image were inherently darker or lighter due to the lighting setup, this would be exacerbated
by the filtering process, making them appear even more pronounced.
3.31 * An image is filtered with a kernel whose coefficients sum to 1. Show that the sum of the pixel values in the
original and filtered images is the same.
3.32 An image is filtered with a kernel whose coefficients sum to 0. Show that the sum of the pixel
values in the filtered image also is 0.
Key Concepts
1. Point of Light Representation: A single point of light in a digital image can be represented as an array of
pixel values where all pixels are 0 (black) except for one pixel, which has a value of 1 (white). This creates a
sharp, discrete representation of the point.
2. Defocused Lens Effect: When light passes through a defocused lens, the sharp point of light is spread out
into a larger, fuzzy blob. The degree of fuzziness depends on how much the lens is defocused. This
spreading of light is a continuous process, where the intensity of light diminishes as you move away from
the center of the blob.
3.34 In the original image used to generate the three blurred images shown, the vertical bars are 5 pix- els wide,
100 pixels high, and their separation is 20 pixels. The image was blurred using square box kernels of sizes 23, 25,
and 45 elements on the side, respectively. The vertical bars on the left, lower part of (a) and (c) are blurred, but
a clear separa- tion exists between them.
3.33 A single point of light can be modeled by a digital image consisting of all 0’s, with a 1 in the location of the
point of light. If you view a single point of light through a defocused lens, it will appear as a fuzzy blob whose size
depends on the amount by which the lens is defocused. We mentioned in Sec- tion 3.5 that filtering an image with
a box kernel is a poor model for a defocused lens, and that a better approximation is obtained with a Gauss- ian
kernel. Using the single-point-of-light analogy, explain why this is so.
The analogy of a single point of light being viewed through a defocused lens helps illustrate the differences
between box kernels and Gaussian kernels in modeling the blurring effect caused by defocus. Here’s a detailed
explanation:
However, the bars have merged in image (b), de- spite the fact that the kernel used to generate this image is much
smaller than the kernel that pro- duced image (c). Explain the reason for this.
The merging of the vertical bars in image (b), despite using a smaller kernel size compared to image (c), can be 2. Kernel Size Requirement: The kernel must be large enough to include both the object and surrounding
explained by considering the effects of the box kernel size on the blurring process and the spatial relationship background pixels. If the kernel size is n×n, the total number of pixels considered in the averaging process
between the bars. is n2.
Key Points to Consider 3. Condition for Reduction: For the average intensity to be reduced to one-tenth, the kernel must include
enough background pixels to dilute the intensity of the object. Specifically, we want: n2(k⋅I)+(b⋅B) =10I
1. Kernel Size and Blurring: The size of the box kernel directly affects the extent of blurring applied to the where:
image. A larger kernel averages over a wider area, which can lead to more significant blurring and merging a. k is the number of object pixels (which is less than q2),
of features. Conversely, a smaller kernel averages over a smaller area, which typically preserves more detail. b. B is the average intensity of the background,
2. Dimensions of the Bars: The vertical bars are 5 pixels wide and 100 pixels high, with a separation of 20 c. b is the number of background pixels included in the kernel.
pixels between them. This means that the distance between the edges of the bars is 20 pixels, which is 4. Solving for Kernel Size: To ensure that the average intensity is reduced to one-tenth, the kernel must
crucial in understanding how the kernels interact with the bars. include enough background pixels such that: b⋅B≫k⋅I This means that the number of background pixels b
3. Kernel Sizes Used: must be sufficiently large compared to the number of object pixels k.
a. Kernel for Image (a): 23 pixels
3.36 With reference to order-statistic filters (see Sec- tion 3.5): (a) * We mentioned that isolated clusters of dark
b. Kernel for Image (b): 25 pixels
or light (with respect to the background) pix- els whose area is less than one-half the area of a median filter are
c. Kernel for Image (c): 45 pixels
forced to the median value of the neighbors by the filter. Assume a filter of size n× n (n odd) and explain why this
4. Blurring Effects: is so. (b) Consider an image having various sets of pixel clusters. Assume that all points in a cluster are lighter or
a. In image (a) with a 23-pixel kernel, the blurring is significant but not enough to cause the bars to darker than the back- ground (but not both simultaneously in the same cluster), and that the area of each clus-
merge, as the kernel size is still smaller than the distance between the edges of the bars (20 pixels). ter is less than or equal to n2 2. In terms of n, under what condition would one or more of these clusters cease to
b. In image (b) with a 25-pixel kernel, the blurring is slightly more pronounced. The kernel size is still be isolated in the sense described in part (a)?
relatively small, but it is large enough to average the pixel values across the edges of the bars, (a) Explanation of Isolated Clusters and Median Filters
especially since the bars are only 5 pixels wide. This can lead to a situation where the edges of the In the context of order-statistic filters, particularly median filters, the behavior of isolated clusters of pixels can be
bars begin to blend into each other, causing them to appear merged. understood as follows:
c. In image (c) with a 45-pixel kernel, the blurring is much more extensive, which results in a significant
merging of the bars. However, the merging effect is more pronounced in image (b) because the 1. Definition of Isolated Clusters: An isolated cluster of pixels is defined as a group of pixels that are
kernel size is just enough to start averaging the pixel values across the edges of the bars, while the significantly different in intensity (either darker or lighter) compared to their surrounding pixels (the
separation is still relatively small. background).
2. Size of the Filter: When using a median filter of size n×n (where n is odd), the filter considers a
neighborhood of n2 pixels around the target pixel. The median filter works by sorting the pixel values in
3.35 Consider an application such as in Fig. 3.41, in which it is desired to eliminate objects smaller than those this neighborhood and selecting the median value to replace the center pixel.
enclosed by a square of size q× q pix- els. Suppose that we want to reduce the average intensity of those objects
3. Area of the Cluster: If the area of the isolated cluster is less than one-half the area of the median filter, it
to one-tenth of their original average value. In this way, their intensity will be closer to the intensity of the
means that the number of pixels in the cluster is less than 2n2 . This is crucial because:
background and they can be eliminated by thresholding. Give the (odd) size of the smallest box kernel that will
yield the desired reduction in average intensity in only one pass of the kernel over the image a. The median is defined as the middle value in a sorted list. In a neighborhood of size n2, if the cluster
To determine the smallest odd-sized box kernel that can reduce the average intensity of objects smaller than those occupies less than half of the neighborhood, the majority of the pixels in the neighborhood will be
enclosed by a square of size q×q pixels to one-tenth of their original average value in a single pass, we need to from the background.
consider the following: b. When the median filter is applied, the sorted list of pixel values will predominantly consist of
background pixel values, with the isolated cluster contributing only a few values.
Key Concepts 4. Effect of the Median Filter: Since the median is determined by the middle value, and the majority of the
1. Box Kernel: A box kernel (or averaging filter) of size n×n (where n is odd) replaces the value of a pixel with values in the sorted list are from the background, the median value will likely be a background pixel value.
the average of the pixel values in its neighborhood defined by the kernel size. Therefore, the isolated cluster's pixel values will be replaced by the median value, effectively "forcing" the
2. Reduction of Intensity: To reduce the average intensity of an object to one-tenth of its original value, the isolated cluster to take on the value of the surrounding background.
kernel must effectively average the pixel values in such a way that the resulting value is significantly lower
than the original.
(b) Condition for Clusters to Cease Being Isolated
3. Kernel Size: The kernel size must be large enough to encompass the object while also averaging in enough To determine the condition under which one or more of these clusters cease to be isolated, consider the following:
background pixels to achieve the desired reduction in intensity.
1. Cluster Size and Filter Size: If each cluster has an area less than or equal to 2n2 , they are considered
isolated because they do not occupy enough space to influence the median value significantly.
Calculation 2. Condition for Isolation: For a cluster to cease being isolated, it must grow in size such that it occupies at
1. Average Intensity Reduction: If the average intensity of the object is I, we want the new average intensity least half of the area of the median filter. This means that if the area of a cluster becomes greater than 2n2
after applying the kernel to be 10I . , it can potentially influence the median value.
3. Mathematical Condition: Therefore, the condition can be expressed as: Area of Cluster>2n2 When this • Reduced Computation: This method significantly reduces the number of operations required, especially
condition is met, the cluster's pixel values can dominate the neighborhood, and the median filter may for large neighborhoods or when processing large images.
select a value from the cluster instead of the background, thus ceasing to be isolated.
3.38 In a given application, a smoothing kernel is applied to input images to reduce noise, then a Laplacian kernel
is applied to enhance fine details. Would the result be the same if the order of these operations is reversed?
In the context of image processing, the order of applying a smoothing kernel and a Laplacian kernel does affect
the final result. Here's a breakdown of the two scenarios:
3.37 Do the following: (a) * Develop a procedure for computing the median of an n× n neighborhood. (b) Propose
a technique for updating the median as the center of the neighborhood is moved from pixel to pixel. 1. Smoothing First, Then Applying the Laplacian
When you first apply a smoothing kernel (such as a Gaussian filter) to reduce noise, you effectively reduce the
(a) Procedure for Computing the Median of an n×n Neighborhood
high-frequency components of the image, which includes noise. After smoothing, when you apply the Laplacian
To compute the median of an n×n neighborhood in an image, follow these steps:
kernel, the operator will enhance the fine details and edges that remain after the noise has been reduced. This
1. Define the Neighborhood: For a given pixel located at (i,j) in the image, define the n×n neighborhood approach typically results in a cleaner image with enhanced features, as the noise that could interfere with the
centered at this pixel. The neighborhood will include pixels from (i−2n ,j−2n ) to (i+2n ,j+2n ), ensuring that edge detection has already been minimized.
you stay within the image boundaries. 2. Applying the Laplacian First, Then Smoothing
2. Extract Pixel Values: Collect the pixel values from the defined neighborhood into a list or array. If you apply the Laplacian kernel first, it will highlight the edges and fine details in the original noisy image,
3. Sort the Values: Sort the collected pixel values in ascending order. including the noise itself. The result will likely contain pronounced edges but also amplified noise, leading to a
4. Compute the Median: noisier output. When you then apply a smoothing kernel to this Laplacian-enhanced image, the smoothing will
a. If n is odd, the median is the middle value in the sorted list: Median=sorted_values[2n2 ] reduce the noise but may also blur some of the fine details that were highlighted by the Laplacian. This can result
b. If n is even, the median is the average of the two middle values: Median=2sorted_values[2n2 in a loss of the very features you intended to enhance.
−1]+sorted_values[2n2 ]
5. Assign the Median: Assign the computed median value to the pixel at (i,j) in the output image.
(b) Technique for Updating the Median as the Center of the Neighborhood
Moves
To efficiently update the median as the center of the neighborhood moves from pixel to pixel, we can use a
technique based on maintaining a sorted list of pixel values. Here’s a proposed method:
1. Initial Median Calculation: Start by calculating the median for the initial n×n neighborhood centered at
the pixel (i,j) using the procedure outlined in part (a).
2. Maintain a Sorted List: Instead of recalculating the median from scratch for each new center, maintain a
sorted list of the pixel values in the current neighborhood.
3. Sliding Window Technique:
a. As the center of the neighborhood moves to a new pixel (i′,j′), update the sorted list:
i. Remove the Outgoing Pixel: Identify the pixel that is no longer in the neighborhood (the
pixel that was at the edge of the previous neighborhood) and remove its value from the
sorted list.
ii. Add the Incoming Pixel: Add the value of the new pixel that is now included in the
neighborhood to the sorted list.
b. Use binary search to efficiently insert the new pixel value and remove the old pixel value from the
sorted list, maintaining the order.
4. Recompute the Median: After updating the sorted list, compute the median using the same method as
in part (a):
a. If n is odd, take the middle value.
b. If n is even, take the average of the two middle values.
5. Repeat: Continue this process as the center of the neighborhood moves across the image.
3.41 * Give a 3x3 kernel for performing unsharp mask- ing in a single pass through an image. Assume that the
average image is obtained using a box filter of size 3x3 .
To create a 3x3 kernel for performing unsharp masking in a single pass through an image, we need to follow the
unsharp masking process, which involves blurring the image and then subtracting this blurred version from the
original image.
Steps to Create the Kernel
1. Box Filter for Blurring: A 3x3 box filter is used to compute the average of the neighboring pixels. The box
filter kernel is:
2. Unsharp Masking Kernel: The unsharp masking process involves subtracting the blurred image from the
original image. To achieve this in a single pass, we can create a kernel that combines the effects of the
original image and the box filter.
3.40 * You saw in Fig. 3.46 that the Laplacian with a −8 in the center yields sharper results than the one with a The unsharp masking kernel can be derived as follows:
−4 in the center. Explain the reason why.
The difference in sharpness between the Laplacian kernels with a center value of −8 and −4 can be attributed to a. The kernel for the original image is represented by a center value of 1.
the strength of the sharpening effect produced by these kernels. Here’s a detailed explanation: b. The kernel for the blurred image (box filter) is represented by negative values that sum to -1.
Therefore, the unsharp masking kernel can be constructed as: is indeed proportional to the unsharp mask, as it enhances the details in the image by subtracting the Laplacian,
which captures the high-frequency components of the image.
3.43 Do the following: (a) * Show that the magnitude of the gradient giv- en in Eq. (3-58) is an isotropic operation
(see the statement of Problem 3.39). (b) Show that the isotropic property is lost in general if the gradient is
computed using Eq. (3-59).
To address the tasks in Problem 3.43, we will analyze the gradient magnitude and its isotropic properties as
described in the equations referenced.
(a) Show that the magnitude of the gradient given in Eq. (3-58) is an isotropic
operation.
The gradient magnitude is typically defined as:
To show that this operation is isotropic, we need to demonstrate that the result does not depend on the orientation
of the input image. An operation is isotropic if it produces the same result regardless of the direction of the input.
3.42 Show that subtracting the Laplacian from an im- age gives a result that is proportional to the un- sharp
mask in Eq. (3-55). Use the definition for the Laplacian given in Eq. (3-53).
1. Gradient Calculation: The gradients gx and gy can be computed using isotropic kernels (like the Sobel or
To show that subtracting the Laplacian from an image results in a result that is proportional to the unsharp mask,
Gaussian kernels) that respond equally to changes in intensity regardless of direction.
we will follow these steps:
2. Magnitude Calculation: The magnitude M(x,y) combines these gradients. Since both gx and gy are derived
1. Define the Laplacian: According to Eq. (3-53), the Laplacian ∇2f(x,y) of an image f(x,y) is defined as: from isotropic operations, their combination in the form of a Euclidean norm (the square root of the sum
of squares) preserves this isotropy.
∇2f(x,y)=∂2f /∂x2 +∂2f /∂y2
Thus, the magnitude of the gradient calculated using Eq. (3-58) is indeed isotropic because it is derived from
In discrete terms, this can be represented using convolution with a kernel that approximates the Laplacian. isotropic gradient components.
2. Unsharp Masking Definition: The unsharp mask technique typically involves creating a blurred version of (b) Show that the isotropic property is lost in general if the gradient is computed
the original image and then subtracting this blurred image from the original to enhance edges. The using Eq. (3-59).
unsharp mask can be mathematically expressed as: Equation (3-59) typically represents a directional gradient calculation that may not be isotropic. For example, it
might use specific directional kernels that are not symmetric or isotropic.
g(x,y)=f(x,y)−k⋅Blur(f(x,y))
1. Directional Kernels: If the gradient is computed using directional kernels (like the Roberts or Prewitt
where g(x,y) is the sharpened image, k is a scaling factor, and Blur(f(x,y)) is a blurred version of the image.
operators), these kernels are designed to respond to changes in specific orientations. For instance, a kernel
3. Relating the Laplacian to Unsharp Masking: When we apply the Laplacian operator to an image, it that emphasizes horizontal edges will not respond equally to vertical edges.
highlights areas of rapid intensity change (edges) and suppresses areas of uniform intensity. The Laplacian 2. Loss of Isotropy: When you compute the gradient using such directional kernels, the resulting gradients
can be thought of as a measure of the second derivative, which indicates how the intensity changes. gx and gy will be sensitive to the orientation of the edges in the image. Consequently, when you compute
the magnitude using these gradients, the result will depend on the orientation of the features in the image.
If we denote the Laplacian of the image as L(x,y)=∇2f(x,y), then we can express the sharpened image as: 3. Example: If you apply a kernel that is sensitive to horizontal edges to a vertical edge, the gradient will yield
a low value, thus affecting the overall magnitude calculation. This demonstrates that the isotropic property
g(x,y)=f(x,y)−k⋅L(x,y)
is lost because the output is now dependent on the orientation of the input features.
Here, k can be set to 1 for simplicity, leading to:
g(x,y)=f(x,y)−∇2f(x,y)
3.44 Are any of the following highpass (sharpening) kernels separable? For those that are, find vectors v and w
4. Proportionality: The result of subtracting the Laplacian from the original image effectively enhances the such that vwT equals the kernel(s). (a) The Laplacian kernels in Figs. 3.45(a) and (b). (b) The Roberts cross-
edges while preserving the overall structure of the image. This is because the Laplacian emphasizes the gradient kernels shown in Figs. 3.50(b) and (c). (c) * The Sobel kernels in Figs. 3.50(d) and (e).
regions of high frequency (edges), and by subtracting it, we are effectively performing an unsharp masking
operation.