0% found this document useful (0 votes)
24 views20 pages

Spatial Resolution

The document explains spatial and intensity resolution in images, highlighting how pixel count affects detail and brightness representation. It also covers image resampling and interpolation techniques, such as nearest-neighbor and bilinear interpolation, which are used to resize images while maintaining quality. The document provides examples and step-by-step processes for resizing images and the effects of different interpolation methods.

Uploaded by

Hira
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views20 pages

Spatial Resolution

The document explains spatial and intensity resolution in images, highlighting how pixel count affects detail and brightness representation. It also covers image resampling and interpolation techniques, such as nearest-neighbor and bilinear interpolation, which are used to resize images while maintaining quality. The document provides examples and step-by-step processes for resizing images and the effects of different interpolation methods.

Uploaded by

Hira
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Spatial Resolution

Spatial resolution refers to the level of detail an image holds, or how


well small structures in the image can be distinguished. It is determined
by the number of pixels used to represent the image. Higher spatial
resolution means that more pixels are used, which allows finer details
to be captured and represented clearly.
For example:
 An image with a high spatial resolution has many pixels per unit
area, making small features appear sharper and more detailed.
 An image with a low spatial resolution has fewer pixels per unit
area, making small features appear blurry or indistinguishable.

Intensity Resolution (Simplified)


Intensity resolution is about how many different shades of brightness
an image can show, from the darkest to the brightest. It depends on
how many bits are used to store each pixel's brightness value:
 Higher intensity resolution means the image can display more
shades, making it look smoother and more realistic.
 Lower intensity resolution means fewer shades are available,
which can make the image look blocky or have harsh transitions
between brightness levels.
Bit Depth and Shades
 1-bit: Only 2 shades (black and white)
 8-bit: 256 shades of gray (common for standard images)
 16-bit: 65,536 shades (used for high-quality or professional
images)
Example
Imagine a sunset:
 With high intensity resolution, the sunset looks smooth, with
gentle color changes.
 With low intensity resolution, the sunset has visible bands of
color, making it look less natural.
In short, higher intensity resolution means more detailed and smoother
images, but it also requires more storage space.

Image Resampling & Interpolation (Simplified)


Image resampling is the process of changing the size of an image, either
by enlarging or shrinking it. This involves adjusting the grid of pixels in
the image to match a new resolution or size. To fill in or calculate new
pixel values, interpolation methods are used.
Interpolation
Interpolation is a technique used to estimate new pixel values when
resizing an image. It helps make the image look smoother and more
natural by filling in gaps (when enlarging) or combining pixels (when
shrinking). Here are some common methods:
1. Nearest-Neighbor Interpolation:
o The simplest method.
o It assigns the value of the nearest original pixel to the new
pixel.
o Pros: Fast and simple.
o Cons: Can result in blocky or jagged images.
2. Bilinear Interpolation:
o Uses the average of the four nearest pixels to calculate a
new pixel value.
o Pros: Smoother than nearest-neighbor, better for gradual
changes.
o Cons: May blur sharp edges slightly.
3. Bicubic Interpolation:
o Uses the average of the sixteen nearest pixels to calculate a
new pixel value.
o Pros: Provides smoother and higher-quality results,
especially for photographs.
o Cons: More computationally intensive.
When to Use Resampling & Interpolation
 Enlarging an Image: Interpolation adds new pixels to make the
image larger and tries to maintain quality.
 Shrinking an Image: Interpolation combines pixels to make the
image smaller while trying to retain important details.
Example
If you have a low-resolution photo and want to enlarge it, interpolation
techniques can help smooth out the pixelation. However, the more you
enlarge, the harder it is to maintain quality, as new details cannot be
created from nothing.
In summary, resampling and interpolation are essential for resizing
images while preserving as much quality as possible.
Image Interpolation –Nearest Neighbor
Original Image (2x2):
css
Copy code
[ 1, 2 ]
[ 3, 4 ]
Goal:
Resize this 2x2 image to a 3x3 image using nearest-neighbor
interpolation.
Step-by-Step Process:
1. Define the scaling factors:
First, we need to calculate how much we need to scale the original
image to match the resized image. The scaling factors for both the rows
and columns are the ratio of the resized size to the original size.
 Original image size: 2x2 (M = 2, N = 2)
 Resized image size: 3x3 (M' = 3, N' = 3)
The scaling factors are:
 Scaling factor for rows (scaley\text{scale}_yscaley):
scaley=M′M=32=1.5\text{scale}_y = \frac{M'}{M} = \frac{3}{2} =
1.5scaley=MM′=23=1.5
 Scaling factor for columns (scalex\text{scale}_xscalex):
scalex=N′N=32=1.5\text{scale}_x = \frac{N'}{N} = \frac{3}{2} = 1.5scalex
=NN′=23=1.5
So, the new image will be 1.5 times larger in both directions (rows and
columns).

2. Map Pixels from Resized Image to Original Image:


Now, for each pixel in the resized image (3x3), we need to find its
corresponding position in the original image (2x2).
Let’s consider each pixel in the resized image one by one:

Pixel (0, 0) in the resized image:


 Calculate the corresponding position in the original image using
the scaling factors: x=01.5=0x = \frac{0}{1.5} = 0x=1.50=0
y=01.5=0y = \frac{0}{1.5} = 0y=1.50=0
 The pixel (0, 0) in the resized image corresponds to (0, 0) in the
original image.
 The value at (0, 0) in the original image is 1.
 So, we set resized image (0, 0) = 1.

Pixel (0, 1) in the resized image:


 Calculate the corresponding position in the original image:
x=11.5≈0.67x = \frac{1}{1.5} \approx 0.67x=1.51≈0.67 y=01.5=0y =
\frac{0}{1.5} = 0y=1.50=0
 The pixel (0, 1) in the resized image corresponds to (0.67, 0) in the
original image.
 We round (0.67, 0) to the nearest integer coordinates, which gives
(0, 0).
 The value at (0, 0) in the original image is 1.
 So, we set resized image (0, 1) = 1.

Pixel (0, 2) in the resized image:


 Calculate the corresponding position in the original image:
x=21.5≈1.33x = \frac{2}{1.5} \approx 1.33x=1.52≈1.33 y=01.5=0y =
\frac{0}{1.5} = 0y=1.50=0
 The pixel (0, 2) in the resized image corresponds to (1.33, 0) in the
original image.
 We round (1.33, 0) to the nearest integer coordinates, which gives
(1, 0).
 The value at (1, 0) in the original image is 2.
 So, we set resized image (0, 2) = 2.

Pixel (1, 0) in the resized image:


 Calculate the corresponding position in the original image:
x=01.5=0x = \frac{0}{1.5} = 0x=1.50=0 y=11.5≈0.67y = \frac{1}{1.5}
\approx 0.67y=1.51≈0.67
 The pixel (1, 0) in the resized image corresponds to (0, 0.67) in the
original image.
 We round (0, 0.67) to the nearest integer coordinates, which gives
(0, 0).
 The value at (0, 0) in the original image is 1.
 So, we set resized image (1, 0) = 1.

Pixel (1, 1) in the resized image:


 Calculate the corresponding position in the original image:
x=11.5≈0.67x = \frac{1}{1.5} \approx 0.67x=1.51≈0.67
y=11.5≈0.67y = \frac{1}{1.5} \approx 0.67y=1.51≈0.67
 The pixel (1, 1) in the resized image corresponds to (0.67, 0.67) in
the original image.
 We round (0.67, 0.67) to the nearest integer coordinates, which
gives (0, 0).
 The value at (0, 0) in the original image is 1.
 So, we set resized image (1, 1) = 1.

Pixel (1, 2) in the resized image:


 Calculate the corresponding position in the original image:
x=21.5≈1.33x = \frac{2}{1.5} \approx 1.33x=1.52≈1.33
y=11.5≈0.67y = \frac{1}{1.5} \approx 0.67y=1.51≈0.67
 The pixel (1, 2) in the resized image corresponds to (1.33, 0.67) in
the original image.
 We round (1.33, 0.67) to the nearest integer coordinates, which
gives (1, 0).
 The value at (1, 0) in the original image is 2.
 So, we set resized image (1, 2) = 2.

Pixel (2, 0) in the resized image:


 Calculate the corresponding position in the original image:
x=01.5=0x = \frac{0}{1.5} = 0x=1.50=0 y=21.5≈1.33y = \frac{2}{1.5}
\approx 1.33y=1.52≈1.33
 The pixel (2, 0) in the resized image corresponds to (0, 1.33) in the
original image.
 We round (0, 1.33) to the nearest integer coordinates, which gives
(0, 1).
 The value at (0, 1) in the original image is 2.
 So, we set resized image (2, 0) = 2.

Pixel (2, 1) in the resized image:


 Calculate the corresponding position in the original image:
x=11.5≈0.67x = \frac{1}{1.5} \approx 0.67x=1.51≈0.67
y=21.5≈1.33y = \frac{2}{1.5} \approx 1.33y=1.52≈1.33
 The pixel (2, 1) in the resized image corresponds to (0.67, 1.33) in
the original image.
 We round (0.67, 1.33) to the nearest integer coordinates, which
gives (0, 1).
 The value at (0, 1) in the original image is 2.
 So, we set resized image (2, 1) = 2.

Pixel (2, 2) in the resized image:


 Calculate the corresponding position in the original image:
x=21.5≈1.33x = \frac{2}{1.5} \approx 1.33x=1.52≈1.33
y=21.5≈1.33y = \frac{2}{1.5} \approx 1.33y=1.52≈1.33
 The pixel (2, 2) in the resized image corresponds to (1.33, 1.33) in
the original image.
 We round (1.33, 1.33) to the nearest integer coordinates, which
gives (1, 1).
 The value at (1, 1) in the original image is 4.
 So, we set resized image (2, 2) = 4.

Final Resized Image (3x3):


After completing this for all the pixels in the resized image, the final 3x3
image looks like this:
css
Copy code
[ 1, 1, 2 ]
[ 1, 1, 2 ]
[ 2, 2, 4 ]
Summary of the Process:
 We calculated the corresponding positions in the original image
for each pixel in the resized image by using scaling factors.
 We then rounded fractional coordinates to the nearest integer,
selecting the closest pixel in the original image.
 Finally, we assigned the values of the nearest pixels from the
original image to the corresponding pixels in the resized image
Bilinear interpolation is a more advanced interpolation technique than
nearest neighbor interpolation. It works by considering the nearest 4
pixels (a 2x2 grid of pixels) around a target pixel and taking a weighted
average of their values. The weights are determined by the distance of
the target pixel from the surrounding pixels.
Here’s how bilinear interpolation works step by step:
Bilinear Interpolation Process:
1. Identify the Four Surrounding Pixels: First, identify the four
nearest pixels in the original image that surround the pixel in the
resized image. These pixels form a 2x2 grid.
2. Find the Relative Distances: Next, calculate how far the target
pixel (in the resized image) is from these four surrounding pixels.
3. Interpolate Horizontally: For each row (horizontal interpolation),
we calculate the weighted average of the two pixels in that row.
4. Interpolate Vertically: Once we have the horizontal interpolations,
we interpolate vertically to get the final pixel value.
Let's walk through the full process of bilinear interpolation using an
example where we resize a 2x2 image to a 3x3 image.
Original Image (2x2):
We have the following original image:
(0,0) (1,0)
10 30
(0,1) (1,1)
20 40
(0,1) (1,1)

This image has 4 pixels, each with a value:


 (0, 0): 10
 (1, 0): 30
 (0, 1): 20
 (1, 1): 40
We want to resize this 2x2 image to a 3x3 image.
Step 1: Calculate the Mapping
We need to figure out how each pixel in the resized 3x3 image
corresponds to a position in the original 2x2 image.
Mapping Formula:
To map the coordinates of the resized image to the original image:
Original coordinates=Resized coordinates×Original sizeResized size\
text{Original coordinates} = \text{Resized coordinates} \times \frac{\
text{Original size}}{\text{Resized
size}}Original coordinates=Resized coordinates×Resized sizeOriginal size
Where:
 Resized size = 3 (for both width and height)
 Original size = 2 (for both width and height)
Resizing Mapping:
For each pixel (i, j) in the resized image:
x′=i3×2x' = \frac{i}{3} \times 2x′=3i×2 y′=j3×2y' = \frac{j}{3} \times 2y′=3j
×2
Where i and j are the coordinates of the pixel in the resized image, and
x' and y' are the corresponding coordinates in the original image.
Let's compute this for each pixel in the 3x3 resized image.
Step 2: Interpolation for Each Pixel
We'll calculate the value for each pixel in the 3x3 resized image using
bilinear interpolation.
Pixel at (0,0) in the resized image:
 Mapped coordinates: x′=0×23=0x' = 0 \times \frac{2}{3} = 0x
′=0×32=0, y′=0×23=0y' = 0 \times \frac{2}{3} = 0y′=0×32=0
 The pixel (0, 0) in the resized image corresponds to pixel (0, 0) in
the original image.
 Value: 10 (from the original image)
Pixel at (1,0) in the resized image:
 Mapped coordinates: x′=1×23=0.67x' = 1 \times \frac{2}{3} =
0.67x′=1×32=0.67, y′=0×23=0y' = 0 \times \frac{2}{3} = 0y′=0×32=0
 Perform horizontal interpolation first between pixels (0, 0) and (1,
0):
o Value at (0, 0) = 10, Value at (1, 0) = 30
o Interpolation:
Interpolated value=10+(30−10)×0.67=10+20×0.67=10+13.34
=23.34\text{Interpolated value} = 10 + (30 - 10) \times 0.67 =
10 + 20 \times 0.67 = 10 + 13.34 =
23.34Interpolated value=10+(30−10)×0.67=10+20×0.67=10+
13.34=23.34
 Value: 23.34
Pixel at (2,0) in the resized image:
 Mapped coordinates: x′=2×23=1.33x' = 2 \times \frac{2}{3} =
1.33x′=2×32=1.33, y′=0×23=0y' = 0 \times \frac{2}{3} = 0y′=0×32=0
 Perform horizontal interpolation between pixels (1, 0) and (2, 0)
(even though we only have 2 columns, we'll treat the next column
as if it’s at the edge of the image):
o Value at (1, 0) = 30, Value at (1, 0) = 30 (since there is no
second column, the value doesn't change)
o Interpolated value: 30
Pixel at (0,1) in the resized image:
 Mapped coordinates: x′=0×23=0x' = 0 \times \frac{2}{3} = 0x
′=0×32=0, y′=1×23=0.67y' = 1 \times \frac{2}{3} = 0.67y′=1×32
=0.67
 Perform vertical interpolation between pixels (0, 0) and (0, 1):
o Value at (0, 0) = 10, Value at (0, 1) = 20
o Interpolation:
Interpolated value=10+(20−10)×0.67=10+10×0.67=10+6.7=1
6.7\text{Interpolated value} = 10 + (20 - 10) \times 0.67 = 10
+ 10 \times 0.67 = 10 + 6.7 =
16.7Interpolated value=10+(20−10)×0.67=10+10×0.67=10+6.
7=16.7
 Value: 16.7
Pixel at (1,1) in the resized image:
 Mapped coordinates: x′=1×23=0.67x' = 1 \times \frac{2}{3} =
0.67x′=1×32=0.67, y′=1×23=0.67y' = 1 \times \frac{2}{3} = 0.67y
′=1×32=0.67
 Perform horizontal interpolation first between pixels (0, 0) and (1,
0):
o Value at (0, 0) = 10, Value at (1, 0) = 30
o Interpolation:
Interpolated value=10+(30−10)×0.67=10+20×0.67=10+13.34
=23.34\text{Interpolated value} = 10 + (30 - 10) \times 0.67 =
10 + 20 \times 0.67 = 10 + 13.34 =
23.34Interpolated value=10+(30−10)×0.67=10+20×0.67=10+
13.34=23.34
 Perform horizontal interpolation between pixels (0, 1) and (1, 1):
o Value at (0, 1) = 20, Value at (1, 1) = 40
o Interpolation:
Interpolated value=20+(40−20)×0.67=20+20×0.67=20+13.34
=33.34\text{Interpolated value} = 20 + (40 - 20) \times 0.67 =
20 + 20 \times 0.67 = 20 + 13.34 =
33.34Interpolated value=20+(40−20)×0.67=20+20×0.67=20+
13.34=33.34
 Vertical interpolation between the values of the horizontal
interpolations:
o Interpolated value:
Final value=23.34+(33.34−23.34)×0.67=23.34+10×0.67=23.3
4+6.7=30.04\text{Final value} = 23.34 + (33.34 - 23.34) \
times 0.67 = 23.34 + 10 \times 0.67 = 23.34 + 6.7 =
30.04Final value=23.34+(33.34−23.34)×0.67=23.34+10×0.67
=23.34+6.7=30.04
 Value: 30.04
Pixel at (2,1) in the resized image:
 Mapped coordinates: x′=2×23=1.33x' = 2 \times \frac{2}{3} =
1.33x′=2×32=1.33, y′=1×23=0.67y' = 1 \times \frac{2}{3} = 0.67y
′=1×32=0.67
 Perform horizontal interpolation between pixels (1, 0) and (1, 0)
(same as before since there's no second column):
o Interpolated value: 30
 Perform horizontal interpolation between pixels (1, 1) and (1, 1):
o Interpolated value: 40
 Vertical interpolation between the values of the horizontal
interpolations:
o Final value:
Final value=30+(40−30)×0.67=30+10×0.67=30+6.7=36.7\
text{Final value} = 30 + (40 - 30) \times 0.67 = 30 + 10 \times
0.67 = 30 + 6.7 =
36.7Final value=30+(40−30)×0.67=30+10×0.67=30+6.7=36.7
 Value: 36.7
Step 3: Continue for Other Pixels
 Repeat similar steps for the remaining pixels in the 3x3 image.
Final 3x3 Resized Image:
After applying the interpolation process, the final resized image will
look like this:
(0,0) (1,0) (2,0)
10 23.34 30
(0,1) (1,1) (2,1)
16.7 30.04 36.7
(0,2) (1,2) (2,2)
30 36.7 40
Summary of the Bilinear Interpolation Process:
1. Map the coordinates: Determine the corresponding positions in
the original image using a resizing mapping formula.
2. Horizontal interpolation: Perform interpolation between adjacent
pixels in the same row.
3. Vertical interpolation: Perform interpolation between the results
of horizontal interpolation.
4. Final result: This gives you the interpolated values for the resized
image.
This process is repeated for each pixel in the resized image, resulting in
smoother transitions between pixel values compared to nearest
neighbor interpolation.
Forward Mapping in Image Resizing
Forward mapping refers to a process where you map each pixel in the
resized image to its corresponding position in the original image. The
main idea is to start with the coordinates of the new image (resized)
and calculate where those coordinates come from in the original image.
Forward Mapping Process:
1. For each pixel in the resized image, calculate where that pixel
should map to in the original image using a mapping function.
2. Using the calculated original coordinates, the value of the
corresponding pixel in the resized image is taken from the original
image using interpolation or other methods.
3. This method is generally used in interpolation techniques like
Bilinear Interpolation or Bicubic Interpolation, where you map
the fractional coordinates in the resized image back to the original
image.
Example of Forward Mapping:
Consider resizing a 2x2 image to a 3x3 image using bilinear
interpolation.
 Let's say you are working on the (1,1) pixel in the 3x3 resized
image.
 Using the forward mapping, you calculate where the pixel should
map to in the 2x2 original image.
o If the original image is 2x2, this means the new pixel's
fractional position might be something like (0.67, 0.67)
(mapped from 1,1 in the resized image).
o In this case, this fractional position is between four original
pixels: (0,0), (1,0), (0,1), and (1,1).
 You can now use bilinear interpolation to assign a value to the
pixel (1,1) in the resized image using the original image’s values.
Problems with Forward Mapping
The forward mapping method can encounter several issues when
resizing images:
1. Gaps in the Resized Image (Empty Pixels)
 Problem: When performing forward mapping, you might
encounter pixels in the resized image that don't map to any
specific pixel in the original image.
o This can happen because the pixel positions in the resized
image might not exactly match any of the original image's
coordinates, leaving gaps or undefined regions.
 Solution: The solution to this issue is to use backward mapping
(explained below) where you start with the original image and
map each original pixel to the corresponding new pixel in the
resized image, ensuring all pixels are filled. Alternatively,
interpolation techniques can be employed to fill in gaps by
averaging neighboring pixels.
2. Misalignment of Pixels (Pixel Duplication or Loss)
 Problem: Since the resized image's coordinates may not perfectly
align with the original image’s pixel grid, some pixels may be
duplicated (i.e., mapped multiple times), or others may be skipped
entirely.
o For example, if you resize a 2x2 image to a 3x3 image, some
pixels in the resized image may be positioned in-between
original pixels, resulting in loss of precision and distortion.
 Solution: Interpolation techniques like bilinear or bicubic
interpolation can help smooth transitions and calculate the
missing pixel values in a more visually appealing way, reducing the
pixel loss or misalignment.
3. Distortion of Image Features
 Problem: Depending on the resizing ratio, the image might
undergo distortion, especially if the original image has distinct
features (like sharp edges or text).
o The distortion can be more pronounced in forward mapping
since the mapping could stretch or compress certain areas of
the image disproportionately.
 Solution: To minimize distortion, it's important to use high-quality
interpolation methods (such as bicubic interpolation) that better
preserve edges and features during resizing. Additionally, using
more sophisticated algorithms like elastic deformation or image
warping may reduce unwanted distortions.
4. Computational Complexity
 Problem: In the case of using more advanced interpolation
methods (e.g., bicubic), forward mapping can become
computationally expensive because it requires multiple
calculations for each pixel (not just simple nearest neighbor
calculations).
 Solution: Optimization techniques like multiresolution
approaches (working with lower-resolution versions of the image
first) can help reduce computational load. Alternatively, backward
mapping can be used, which is sometimes more efficient
depending on the method.
Backward Mapping as a Solution
Backward mapping is an alternative to forward mapping, and it
addresses many of the problems associated with forward mapping.
What is Backward Mapping?
 In backward mapping, you start with the original image's pixel
coordinates and map them to the resized image.
 Instead of calculating where a resized image pixel corresponds in
the original image (which can lead to gaps or duplications),
backward mapping calculates where each pixel in the original
image will end up in the resized image.
Advantages of Backward Mapping:
 No gaps: It avoids the issue of gaps or unassigned pixels.
 Better precision: It can prevent loss of information because each
original pixel has a clear destination.
 Efficient handling of coordinates: By mapping from original to
resized, you avoid some of the computation overhead in forward
mapping.
In many cases, backward mapping is preferred over forward mapping,
as it avoids issues like gaps, misalignment, and distortion. However,
depending on the application, the choice of mapping can vary, and both
approaches can be combined for optimal results.
4o mini

You might also like