Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

Tutorial_2._Arithmetic_OperatioN

The document is a practical report on digital image processing, focusing on arithmetic operations such as addition, subtraction, multiplication, and division of images using MATLAB functions. It outlines the goals, objectives, required materials, and procedures for performing these operations, along with questions to assess understanding of the concepts. The report also discusses the implications of these operations in image analysis and manipulation, including techniques for enhancing image details and extracting backgrounds.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Tutorial_2._Arithmetic_OperatioN

The document is a practical report on digital image processing, focusing on arithmetic operations such as addition, subtraction, multiplication, and division of images using MATLAB functions. It outlines the goals, objectives, required materials, and procedures for performing these operations, along with questions to assess understanding of the concepts. The report also discusses the implications of these operations in image analysis and manipulation, including techniques for enhancing image details and extracting backgrounds.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

LAPORAN PRAKTIKUM PENGOLAHAN CITRA DIGITAL

2. ARITHMETIC OPERATIONS

Disusun oleh :
Nama : Fawwaz Syadza Kanzsakha
NPM : 2226250080
Kelas : IF4B

PROGRAM STUDI INFORMATIKA


FAKULTAS ILMU KOMPUTER DAN REKAYASA
UNIVERSITAS MULTI DATA PALEMBANG
2024

1
TUTORIAL 2. ARITHMETIC OPERATIONS

Goal
The goal of this tutorial is to learn how to perform arithmetic operations on images.

Objectives
 Learn how to perform image addition using the imadd function.
 Explore image subtraction using the imsubtract function.
 Explore image multiplication using the immultiply function.
 Learn how to use the imdivide function for image division.

What You Will Need


 cameraman2.tif
 earth1.tif
 earth2.tif
 gradient.tif
 gradient_with_text.tif

Procedure
The IPT offers four functions to aid in image arithmetic: imadd, imsubtract, immultiply,
and imdivide. You could use MATLAB’s arithmetic functions (+, −, *, /) to perform image
arithmetic, but it would probably require additional coding to ensure that the operations
are performed in double precision, as well as setting cutoff values to be sure that the result
is within grayscale range. The functions provided by the IPT do this for you automatically.
Image addition can be used to brighten (or darken) an image by adding (subtracting) a
constant value to (from) each pixel value. It can also be used to blend two images into one.

1. Use the imadd function to brighten an image by adding a constant (scalar) value to
all its pixel values.

2
Question 1 What are the maximum and minimum values of the original and the
adjusted image? Explain your results.
Nilai maksimumnya adalah sebesar 255 dan nilai minimum dari gambar asli
adalah sebesar 0 dan gambar yang disesuaikan adalah sebesar 75. Mengubah
nilai Y sebesar 75 di I2 tidak mempengaruhi ukuran gambar yang disesuaikan.
max(I(:)); >> ans = 255
min(I(:)); >> ans = 0
max(I2(:)); >> ans = 255
min(I2(:)); >> ans = 75

Question 2 How many pixels had a value of 255 in the original image and how
many have a value of 255 in the resulting image?
There are Ada sekitar 301 piksel berisi 255 piksel pada gambar asli dan 2614
piksel berisi 255 piksel pada gambar yang disesuaikan. about 301 pixels
contains 255 in the original image and 2614 pixels contains 255 in the adjusted
image.
konv1=I==255;
konv2=I2==255;
jmlhpix1=sum(konv1(:));
jmlhpix2=sum(konv2(:));

2. Use the imadd function to blend two images.

Image subtraction is useful when determining whether two images are the same. By
subtracting one image from another, we can highlight the differences between the two.

3. Close all open figures and clear all workspace variables.


4. Load two images and display them.

3
While it may not be obvious at first how the altered image differs from the original image,
we should be able to see where the difference is located after using the imsubtract
function.

5. Subtract both images and display the result.

6. Use the zoom tool to zoom into the right area of the difference image about halfway
down the image. You will notice that a small region of pixels is faintly white.
7. To zoom back out, double-click anywhere on the image.

Now that you know where the difference is located, you can look at the original images to
see the change. The difference image above does not quite seem to display all the details of
the missing building. This is because when we performed image subtraction, some of the
pixels resulted in negative values, but were then set to 0 by the imsubtract function (the
function does this on purpose to keep the data within grayscale range). What we really
want to do is calculate the absolute value of the difference between two images.

8. Calculate the absolute difference. Make sure Figure 2 is selected before executing
this code.

9. Use the zoom-in tool to inspect the new difference image

Even though the new image may look the same as the previous one, it represents both
positive and negative differences between the two images. To see this difference better, we
will scale both difference images for display purposes, so their values occupy the full range
of the gray scale.

10. Show scaled versions of both difference images.

11. Use the zoom tool to see the differences between all four difference images.

Question 3 How did we scale the image output?


Kita dapat menskalakan gambar dengan menggunakan fungsi imshow(diffim,[])
dengan parameter kedua

Question 4 What happened when we scaled the difference images?


Kami akan menskalakan kedua gambar yang berbeda untuk tujuan tampilan,
sehingga nilainya menempati seluruh rentang skala abu-abu.

Question 5 Why does the last image show more detail than the others?
Karena gambar terakhir menunjukkan nilai yang lebih besar dari 255 dan yang

4
kurang dari 0, yang memberikan detail tambahan dengan menunjukkan
perbedaan negatif dan positif pada gambar perbedaan.

Multiplication is the process of multiplying the values of each pixel of same coordinates in
two images. This can be used for a brightening process known as dynamic scaling, which
results in a more naturally brighter image compared to directly adding a constant to each
pixel.

12. Close all open figures and clear all workspace variables.

13. Use immultiply to dynamically scale the moon image.

Question 6 When dynamically scaling the moon image, why did the dark regions
around the moon not become brighter as in the normally adjusted image?
Karena pada gambar aslinya, area bulan gelap memiliki nilai 0 piksel. Jadi ketika
proses penskalaan dinamis dilakukan dengan mengalikan 50 piksel, tidak
berpengaruh pada nilai intensitasnya.

Image multiplication can also be used for special effects such as an artificial 3D look. By
multiplying a flat image with a gradient, we create the illusion of a 3D textured surface.

14. Close all open figures and clear all workspace variables.

15. Create an artificial 3D planet by using the immultiply function to multiply the
earth1 and earth2 images.

Image division can be used as the inverse operation to dynamic scaling. Image division is
accomplished with the imdivide function. When using image division for this purpose,
we can achieve the same effect using the immultiply function.

16. Close all open figures and clear all workspace variables.

17. Use image division to dynamically darken the moon image.

5
18. Display the equivalent darker image using image multiplication.

Question 7 Why did the multiplication procedure produce the same result as
division?
Karena 0.5 adalah ½. Perkalian dengan 0,5 sama dengan membagi dengan 2.

Question 8 Write a small script that will verify that the images produced from
division and multiplication are equivalent.
persamaan=bitxor(I2,I3);
notzero=jumlah(eq(:)~=0);

Another use of the image division process is to extract the background from an image. This
is usually done during a preprocessing stage of a larger, more complex operation.

19. Close all open figures and clear all workspace variables.

20. Load the images that will be used for background subtraction.

This image could represent a document that was scanned under inconsistent lighting
conditions. Because of the background, the text in this image cannot be processed directly
—we must preprocess the image before we can do anything with the text. If the
background were homogeneous, we could use image thresholding to extract the text pixels
from the background. Thresholding is a simple process of converting an image to its binary
equivalent by defining a threshold to be used as a cutoff value: anything below the
threshold will be discarded (set to 0) and anything above it will be kept (set to 1 or 255,
depending on the data class we choose).

21. Show how thresholding fails in this case.

Although the specifics of the thresholding operation (using built-in functions


graythresh and im2bw) are not important at this time, we can see that even though we
attempted to segregate the image into dark and light pixels, it produced only part of the
text we need (on the upper right portion of the image). If an image of the background with

6
no text on it is available, we can use the imdivide function to extract the letters. To
obtain such background image in a real scenario, such as scanning documents, a blank
page that would show only the inconsistently lit background could be scanned.

22. Divide the background from the image to get rid of the background.

Question 9 Would this technique still work if we were unable to obtain the
background image?
We can create a masking for the image with roipoly function.

You might also like