0% found this document useful (0 votes)
21 views

TI by OpenAI

The document discusses several topics related to digital image processing including: 1) Definitions of digital images, histograms, and contours. 2) Examples of filters and their roles in image processing. 3) The steps involved in histogram equalization of an image. It also provides sample C code to implement histogram equalization and discusses the differences between intensity profiles and histograms of an image.

Uploaded by

Tanankem
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

TI by OpenAI

The document discusses several topics related to digital image processing including: 1) Definitions of digital images, histograms, and contours. 2) Examples of filters and their roles in image processing. 3) The steps involved in histogram equalization of an image. It also provides sample C code to implement histogram equalization and discusses the differences between intensity profiles and histograms of an image.

Uploaded by

Tanankem
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

2020/2021

TI(SR)

Exercise 1
1.
 Digital image: A digital image is a representation of a two-dimensional image in the
form of numerical values, typically rectangular pixels arranged in a grid. Digital
images can be created by scanning an analog image or creating an image directly
with image editing software. They can be stored and transmitted electronically and
can be displayed on a computer or other digital device. Digital images are widely
used in the fields of photography, graphic design, and computer vision and have
many advantages over analog images, such as the ability to easily edit, transmit, and
store them.
 Image histogram: An image histogram is a graphical representation of the
distribution of gray levels in the image. It is presented as a bar chart showing the
number of occurrences of each gray level in the image. An image histogram can be
used to evaluate the quality of the image and to optimize its contrast and brightness
by adjusting the distribution of gray levels.
 Contour: A contour is a line or area outlining a shape or object in an image. Contours
can be used to define the boundaries of objects in an image, to distinguish between
different parts of an object, or to highlight features of an object.

2.
a. True - Histogram equalization of two differently contrasted identical images will
yield different results.
b. False - There are several color spaces, such as RGB (red, green, blue), CMYK (cyan,
magenta, yellow, black), and HSL (hue, saturation, luminosity).

3. Two examples of filters and their roles:


 Low pass filter: used to remove noise from the image by smoothing out variations in
gray levels.
 High pass filter: used to highlight details in the image by accentuating variations in
gray levels.

4. Steps of histogram equalization:


Step 1: Calculate the histogram of the image.
Step 2: Calculate the probability distribution of the histogram.
Step 3: Calculate the transfer function of the equalized histogram.
Step 4: Apply the transfer function to the image to obtain the equalized image.
Mathematical formulas:
Step 1: histogram[i] = number of occurrences of gray level i in the image
Step 2: probability[i] = histogram[i] / (width of image * height of image)
Step 3: transfer function[i] = sum of probabilities[j] for j from 0 to i
Step 4: equalized image[i, j] = transfer function[image[i, j]]

5. Types of contours:
 External contour: outlines the boundary of the object in the image.
 Internal contour: outlines the different parts of the object in the image.
 Hollow contour: outlines the raised parts of the object in the image.
 Raised contour: outlines the hollow parts of the object in the image.

6. The intensity profile of an image is a graphical representation of the intensity of the


image along a line or path in the image. The histogram of an image is a graphical
representation of the distribution of gray levels in the image. Thus, the intensity profile
of an image shows how the intensity varies along a line or path in the image, while the
histogram of an image shows the overall distribution of gray levels in the image.

Exercise 2

1. (see 2021/2022 SN)


2. (see 2021/2022 SN)
3. (trivial)
4.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define IMAGE_WIDTH 256


#define IMAGE_HEIGHT 256
#define GRAY_LEVELS 256

// Function prototype for histogram equalization


void histogram_equalization(unsigned char image[][IMAGE_WIDTH]);

int main()
{
// Read input image
unsigned char image[IMAGE_HEIGHT][IMAGE_WIDTH];
FILE* fp = fopen("input.raw", "rb");
fread(image, sizeof(unsigned char), IMAGE_WIDTH * IMAGE_HEIGHT, fp);
fclose(fp);

// Perform histogram equalization


histogram_equalization(image);
// Write output image
fp = fopen("output.raw", "wb");
fwrite(image, sizeof(unsigned char), IMAGE_WIDTH * IMAGE_HEIGHT, fp);
fclose(fp);

return 0;
}

// Histogram equalization function


void histogram_equalization(unsigned char image[][IMAGE_WIDTH])
{
// Calculate histogram and probability distribution
int histogram[GRAY_LEVELS] = {0};
float probability[GRAY_LEVELS];
for (int i = 0; i < IMAGE_HEIGHT; i++)
{
for (int j = 0; j < IMAGE_WIDTH; j++)
{
histogram[image[i][j]]++;
}
}
for (int i = 0; i < GRAY_LEVELS; i++)
{
probability[i] = (float)histogram[i] / (IMAGE_WIDTH * IMAGE_HEIGHT);
}

// Calculate transfer function and apply it to image


int transfer_function[GRAY_LEVELS];
for (int i = 0; i < GRAY_LEVELS; i++)
{
transfer_function[i] = (int)(255 * probability[i] + 0.5);
}
for (int i = 0; i < IMAGE_HEIGHT; i++)
{
for (int j = 0; j < IMAGE_WIDTH; j++)
{
image[i][j] = transfer_function[image[i][j]];
}
}
}
TI(SN)

Exercise 1
(See SR same year)

Exercise 2

a. The result of the convolution, ignoring edge effects, is:


[56, 64] * [1, -1] = 56 - 64 = -8
[64, 79] * [1, -1] = 64 - 79 = -15
[79, 98] * [1, -1] = 79 - 98 = -19
[98, 115] * [1, -1] = 98 - 115 = -17
[115, 126] * [1, -1] = 115 - 126 = -11
[126, 132] * [1, -1] = 126 - 132 = -6
[132, 133] * [1, -1] = 132 - 133 = -1

b. There are two edges in this image, located at index 2 and index 3. The Robert
filter identifies edges by looking for rapid changes in intensity, which is why it
outputs a large negative value at index 2 and a large positive value at index 3.

c. In practice, edge detectors often detect many other lines in an image that are
not "object edges". This is because edge detectors are sensitive to any rapid
changes in intensity, regardless of whether they are caused by actual object
boundaries or other factors such as noise or texture. Some examples of other
types of lines that may be detected by an edge detector include:
 Noise: Random fluctuations in intensity caused by factors such as electronic
noise or variations in lighting can be misinterpreted as edges by an edge
detector.
 Texture: Patterns or repeating structures in an image, such as the texture of a
surface or the lines in a checkerboard, can also be detected as edges.
 Shadows: Shadows cast by objects in an image can create rapid changes in
intensity that may be interpreted as edges by an edge detector.

Exercise 3

1. (See 2021/2022 SN)


2. (See 2021/2022 SN)
3. (See SR same year)

You might also like