0% found this document useful (0 votes)
17 views17 pages

Image Processing Lab 02

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

Image Processing Lab 02

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

Image Processing

Lab 02
Eng. Gamal Essam
Agenda

➢Point Processing
➢Transformation Functions

➢Contrast Stretching

➢MATLAB Time
Point Processing
Transformation Functions
❑Transformation is a function that maps one set to
another set after performing some operations.
❑Consider this equation G(x,y) = T{ f(x,y) }
❑In this equation,
❑F(x,y) = input image on which transformation function
has to be applied.
❑G(x,y) = the output image or processed image.
❑T is the transformation function.
❑This relation between input image and the processed
output image can also be represented as → s = T (r)
Point Processing
Logarithmic Transformation
❑Log transformation maps narrow range of low input grey level values into a wider
range (bright images)
❑𝐬 = 𝒄 × 𝐥𝐨𝐠 𝟏 + 𝒓 : 𝒘𝒉𝒆𝒓𝒆 𝒓 𝒊𝒔 𝒈𝒓𝒆𝒚 𝒍𝒆𝒗𝒆𝒍
❑Inverse Log perform the opposite operation
❑𝐬 = 𝒆𝒙𝒑 𝒓 ∶ 𝒘𝒉𝒆𝒓𝒆 𝒓 𝒊𝒔 𝒈𝒓𝒆𝒚 𝒍𝒆𝒗𝒆𝒍
❑Logarithmic operation deals with values from 0 to 1.
❑Note that the log and inverse log better than the brightness function which we
have taken previous section, since log and inverse keeps some details of image
unlike another method.
Point Processing
Logarithmic Transformation
Point Processing
Power-Law “Gamma” Transformation
❑General Form → 𝐬 = 𝒄 × 𝒓𝜸 : 𝒘𝒉𝒆𝒓𝒆 𝒓 𝒊𝒔 𝒈𝒓𝒆𝒚 𝒍𝒆𝒗𝒆𝒍
❑Gamma transformation with value less than 1 maps narrow range of low input
grey level values into a wider range (bright images)
❑Gamma transformation with value more than 1 perform the opposite operation
❑Power-Law operation deals with values from 0 to 1.
❑Note that the log and inverse log better than the brightness function which we
have taken previous section, since log and inverse keeps some details of image
unlike another method.
Point Processing
Power-Law “Gamma” Transformation
Point Processing
Negative Transformation
❑General Form → 𝐬 = 𝑳 − 𝟏 − 𝒓 ∶ 𝒘𝒉𝒆𝒓𝒆 𝒓 𝒊𝒔 𝒈𝒓𝒆𝒚 𝒍𝒆𝒗𝒆𝒍
Point Processing
Contrast Stretching
❑Contrast Stretching is a simple image enhancement technique that attempts to
improve the contrast in an image by `stretching' the range of intensity values it
contains to span a desired range of values.
Point Processing
Contrast Stretching
❑General Equation
𝐏𝐢𝐱𝐞𝐥 − 𝐌𝐢𝐧𝐨𝐥𝐝
❑𝐏𝐢𝐱𝐞𝐥𝐧𝐞𝐰 = × 𝐌𝐚𝐱𝐧𝐞𝐰 − 𝐌𝐢𝐧𝐧𝐞𝐰 + 𝐌𝐢𝐧𝐧𝐞𝐰
𝐌𝐚𝐱 𝐨𝐥𝐝 −𝐌𝐢𝐧𝐨𝐥𝐝

❑Example
MATLAB TIME
Creating Functions
Creating Functions
How to get size and dealing with an
image in MATLAB ?
❑We get size of an image by using “size(image variable)”
❑Its return [H W L]
➢ H → height of image
➢ W → width of image
➢ L → depth of image : it will be 3 if you pass RGB image
❑We dealing with an image in MATLAB by making a nested for loop to
pass through the image
❑Some help functions we will need
❑im2double → convert [0-255] to [0-1]
❑im2uint8 → convert [0-1] to [0-255]
❑min(min(img)) → for min value in matrix
❑max(max(img)) → for max value in matrix
❑zeros(h, w) → for creating zeros matrix
❑ones(h, w) → for creating ones matrix
Creating Functions
List of image file names in MATLAB
• AT3_1m4_01.tif • cameraman.tif • glass.png • office_5.jpg • testpat1.png

• AT3_1m4_02.tif • canoe.tif • greens.jpg • office_6.jpg • text.png

• AT3_1m4_03.tif • cell.tif • hestain.png • onion.png • tire.tif

• AT3_1m4_04.tif • circbw.tif • kids.tif • paper1.tif • tissue.png

• AT3_1m4_05.tif • circles.png • liftingbody.png • pears.png • trees.tif

• AT3_1m4_06.tif • circuit.tif • logo.tif • peppers.png • westconcordaerial.png

• AT3_1m4_07.tif • coins.png • m83.tif • pillsetc.png • westconcordorthophoto.png

• AT3_1m4_08.tif • concordaerial.png • mandi.tif • pout.tif

• AT3_1m4_09.tif • concordorthophoto.png • moon.tif • rice.png

• AT3_1m4_10.tif • eight.tif • mri.tif • saturn.png

• autumn.tif • fabric.png • office_1.jpg • shadow.tif

• bag.png • football.jpg • office_2.jpg • snowflakes.png

• blobs.png • forest.tif • office_3.jpg • spine.tif

• board.tif • gantrycrane.png • office_4.jpg • tape.png


Creating Functions
Build RGB_2_Gray in MATLAB ?
Creating Functions
Build RGB_2_Gray in MATLAB ?
Creating Functions
Task
❑Write .m file for the following functions.
Function Input
1 RGB_2_Gray ➢ RGB image
2 Image_2_BW ➢ RGB or Gray image
3 Image_2_Negative ➢ RGB or Gray image
➢ RGB or Gray image
4 Image_Linear_Operation
➢ Operation → + - / *
➢ RGB or Gray image
5 Image_Contrast_Stretching
➢ New Range
6 Log_Image, Inverse_Log_Image ➢ RGB or Gray image
➢ RGB or Gray image
7 Gamma_Correction_Image
➢ Gamma value

You might also like