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

Asistio Module2 Activity

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)
7 views

Asistio Module2 Activity

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/ 9

Asistio, Mark Edisol M.

BSCPE-3A
Module 2: Activity
Assignment No.1
1. Pick any greyscale image. Using the imwrite function,write it to files of type JPEG, PNG
and BMP. What are the sizes of those files in MB?
2. Repeat the above question with (a) a binary image, (b) an indexed color image, (c) a
true color image.

1.

2.

Quiz
1:
Apply
imread
()

function of a .tiff image. Translate to greyscale and view


the image. From the image result, apply im2uint8( ). What
does the function im2uint8 do? What affect does it have on (a) the appearance of the image?
(b) the elements of the image matrix?
- The function
im2uint8
converts an
image to an
unsigned 8- bit
integer
format. This is
a common
format for
images,
where pixel values range from 0 to 255.
Effects of im2uint8
(a) The Appearance of the Image:
1. Grayscale Image with Double or Single Data Type:
- If the image is stored as a double or single with pixel values ranging from 0 to 1,
im2uint8 scales these values to the range 0 to 255.
2. Image with Integer Data Types:
- If the image is already in an integer format but with a different range (e.g., 16-bit
integers with values from 0 to 65535), im2uint8 scales these values to fit within the 0 to
255 range. This may change the appearance because of the change in dynamic range.
3. Images with Values Outside Standard Ranges:
- If the image has pixel values outside the standard 0 to 1 range (for double/single) or 0 to
255 range (for integers), im2uint8 will clip values outside the range 0 to 1 (for
double/single) before scaling. Values below 0 are set to 0, and values above 1 are set to
255. This can lead to loss of detail or contrast in the image.

(b) The Elements of the Image Matrix


1. Data Type Conversion:
- The function converts the image matrix to an unsigned 8-bit integer (uint8). This means
each element in the image matrix will now be an integer between 0 and 255.
2. Scaling of Values:
For images with double or single data types:
• Pixel values originally between 0 and 1 are scaled to the range 0 to 255.
For images with integer data types:
• Values are linearly mapped to the 0 to 255 range if they are not already
within this range.

Module 3
Assignment 2:

Image Arithmetic Functions

Learning Outcome
At the end of the exercise, the student will be able to:
1. Perform standard arithmetic operations such as addition, subtraction, multiplication, and
division on images.
2. Identify the effects of the different arithmetic operations on images.

Image arithmetic is the implementation of standard arithmetic operations on images. In image


processing, it can be used as a preliminary step in more complex operations (i.e. image subtraction can
be used to detect differences between two or more images of the same scene or object).

One can perform image arithmetic using the Scilab arithmetic operators. The Image Processing
Toolbox includes a set of functions that implement arithmetic operations for all numeric, nonsparse data
types such as uint8, uint16, and double, and return the result image in the same format. These functions
perform the operations in double precision, on an element-by-element basis, but do not convert images
to double-precision values in the workspace. Overflow is handled automatically. The functions saturate
return values to fit the data type.

These arithmetic operations act by applying a simple function to each grey value in the image:
y=f(x)
Thus f(x) is a function which maps the range 0-255 onto itself. Simple functions include adding or
subtracting a constant value to each pixel:
y = x + C or y = x - C
and multiplying or dividing each pixel by a constant:
y = C x or y = x / C
In each case, performing these operations may result to values outside the range of 0-255. To ensure
that the results are within the range, we need to round off the values to obtain an integer and then
clipping the values:
If y > 255, then y = 255 or if y < 0, then y = 0
It should be noted that Scilab handles this case automatically.

Procedure
1. We can test this on the image “cameraman.tif”. We start by reading the image in:
>> y = imread (‘cameraman.tif’);
>>figure (1), imshow (y)
Copy the image and place it the space provided under the label “Figure 1. Original Image”
2. Perform addition on the image by entering either of the commands:
>> Add_y = y + 128;
or
>> Add_y = imadd ( y, 128 );
>>figure (2), imshow (Add_y)
Copy the image and place it the space provided under the label “Figure 2. Addition”
3. Perform subtraction on the image by entering either of the commands:
>> Sub_y = y + 128;
or
>> Sub_y = imsubtract ( y, 128 );
>> figure (3), imshow (Sub_y)
Copy the image and place it the space provided under the label “Figure 3. Subtraction”
4. Perform multiplication on the image by entering either of the commands:
>> Mul_y = y * 2;
or
>> Mul_y = immultiply ( y, 2 );
>> figure (4), imshow (Mul_y)
Copy the image and place it the space provided under the label “Figure 4. Multiplication”
5. Perform division on the image by entering either of the commands:
>> Div_y = y / 2;
or
>> Div_y = imdivide ( y, 2 );
>> figure (5), imshow (Div_y)
Copy the image and place it the space provided under the label “Figure 1. xxx”
Figure 1. Original Image Figure 2. Addition Figure 3. Subtraction

Figure 4. Multiplication Figure 5. Division


Questions
1. What have you observed on the image after the following arithmetic operations were
performed?
a. Addition
- Adding a constant value to an image increases the brightness of the image.
b. Subtraction
- Subtracting a constant value from an image decreases the brightness of the image.
c. Multiplication
- Multiplying an image by a constant factor increases or decreases the contrast. Values greater
than 1 increase brightness and contrast, while values between 0 and 1 decrease them.
d. Division
- Dividing an image by a constant factor reduces the brightness and contrast. Pixels with low
values may become very dark, but there is less risk of clipping compared to addition and
multiplication.
2. What generalization can you come up?
- Arithmetic Operations on Images can significantly alter the image's appearance by
modifying its brightness and contrast.
- Addition/Subtraction: Primarily affect brightness, with risks of clipping at the extremes
(0 or 255).
- Multiplication/Division: Affect both brightness and contrast, with potential for more
complex clipping scenarios.

Quiz 3

Consider the following 8 x 8 image:

3 148 117 148 145 178 132 174


2 176 174 110 185 155 118 165
0 100 124 113 193 136 146 108
0 155 170 106 158 130 178 170
9 196 138 113 108 127 144 139
6 188 143 183 137 162 105 169
9 122 156 119 188 179 100 151
8 176 137 114 135 123 134 183
1. Threshold it at

(a) level 100


(b) level 150

1. What happens to the results of thresholding as the threshold level is increased?


- Increasing the threshold level in MATLAB results in a binary image that shifts from
mostly white to black. At lower threshold levels, most pixel values exceed the
threshold, resulting in more pixels set to white (255). As the threshold level
increases, more pixels fall below it and are set to black (0). At high threshold
settings, most pixel values fall below the threshold, resulting in largely black
images. This effect is important in image processing because it affects object
appearance and segmentation by showing how pixel intensity distribution interacts
with threshold settings.

2. The following tables give the number of pixels at each of the grey levels – in an
image with those grey values only. In each case draw the histogram
corresponding to these grey levels, and then perform a histogram equalization
and draw the resulting histogram.
a.

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
20 40 60 75 80 75 65 55 50 45 40 35 30 25 20 30
b.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 0 40 80 45 110 70 0 0 0 0 0 0 0 0 15
A.
B.

You might also like