Top Banner
COMPUTER VISION LAB LAB 0 Gemma Rotger Felipe Lumbreras Spring 2017
16

COMPUTER VISION LAB - UAB Barcelona · LAB 0 –PROBLEM 5 The image histogram gives an idea about how the colour/intensity is represented along the image. Is the image dark, is it

Aug 06, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: COMPUTER VISION LAB - UAB Barcelona · LAB 0 –PROBLEM 5 The image histogram gives an idea about how the colour/intensity is represented along the image. Is the image dark, is it

COMPUTER VISION LAB

LAB 0

Gemma Rotger – Felipe Lumbreras

Spring 2017

Page 2: COMPUTER VISION LAB - UAB Barcelona · LAB 0 –PROBLEM 5 The image histogram gives an idea about how the colour/intensity is represented along the image. Is the image dark, is it

LAB 0 – PROJECT GOALS

• Get familiar with Matlab and/or Octave.

• Learn how to work with images in Matlab and Octave

• Use Matlab and/or Octave to perform some Image Processing methods over images.

Deliverable deadline: Th. Feb. 23th. 23:00h

Page 3: COMPUTER VISION LAB - UAB Barcelona · LAB 0 –PROBLEM 5 The image histogram gives an idea about how the colour/intensity is represented along the image. Is the image dark, is it

LAB 0 – PROJECT MATERIALS

You can find the project materials in Cerbero:

• Code• Lab0.m

• Source Images • cameraman.jpg

• sat_map2.jpg

• t22.jpg

• pict0004.png

• alice.jpg

Page 4: COMPUTER VISION LAB - UAB Barcelona · LAB 0 –PROBLEM 5 The image histogram gives an idea about how the colour/intensity is represented along the image. Is the image dark, is it

LAB 0 – PROBLEM 1

Reading an image with Matlab is super easy, you can find all the information on the following link:

http://es.mathworks.com/help/matlab/ref/imread.html

Also it is very easy with Octave:

https://www.gnu.org/software/octave/doc/interpreter/Loading-and-Saving-Images.html

PROBLEM 1. The following image, the cameraman, is one of themost widely used images for Computer Vision scientists.Download it and load in your Matlab or Octave workplace (+0.5).

And don’t forget to put ; after the instruction in order to avoid plotting the image values on the command window

Page 5: COMPUTER VISION LAB - UAB Barcelona · LAB 0 –PROBLEM 5 The image histogram gives an idea about how the colour/intensity is represented along the image. Is the image dark, is it

CAUTION

You can deal with paths easily.

1. Create a folder on your workspace and name it images.2. When you refer to an image use a relative path like

'images/image.png'.3. Or use the instruction addpath(‘images’) to add the sub

directory to your workspace.

BE CAREFUL WITH ABSOLUTE PATHS!

WARNING: If I can't execute your code in my computer because you can lead with paths you won’t pass this part.

Page 6: COMPUTER VISION LAB - UAB Barcelona · LAB 0 –PROBLEM 5 The image histogram gives an idea about how the colour/intensity is represented along the image. Is the image dark, is it

LAB 0 – PROBLEM 2

Matlab reference: http://es.mathworks.com/help/matlab/ref/imshow.html?searchHighlight=imshow

Octave reference:

https://www.gnu.org/software/octave/doc/interpreter/Displaying-Images.html

PROBLEM 2. Now you have loaded you image, please, show it to

me using imshow! (+0.5).

In MATLAB this is called figure

Page 7: COMPUTER VISION LAB - UAB Barcelona · LAB 0 –PROBLEM 5 The image histogram gives an idea about how the colour/intensity is represented along the image. Is the image dark, is it

LAB 0 – PROBLEM 3

PROBLEM 3. Negative efect. (+1.5)

The negative effect is just the inverse of the

image. It can be computed by subtracting the

maximum value (f. e. 255) to each pixel value.

𝑁𝑒𝑔 𝑖, 𝑗 = 255 − 𝐼(𝑖, 𝑗)

Do this exercise twice, one with a double loop

for and one using the MATLAB matrix form. Use

the instruction tic toc in both cases to see the

difference in performance

Page 8: COMPUTER VISION LAB - UAB Barcelona · LAB 0 –PROBLEM 5 The image histogram gives an idea about how the colour/intensity is represented along the image. Is the image dark, is it

LAB 0 – PROBLEM 4

PROBLEM 4. Give some colour. (+3.5)

You can paint a grey image to look colourful

like the one on the right by playing with the

RGB values. Just follow this steps:

1. Triplicate the original image to use in the

three different channels.

Page 9: COMPUTER VISION LAB - UAB Barcelona · LAB 0 –PROBLEM 5 The image histogram gives an idea about how the colour/intensity is represented along the image. Is the image dark, is it

LAB 0 – PROBLEM 4

Take into account which value range should

have these multipliers to avoid overflow.

𝐶𝑜𝑙 𝑖, 𝑗 = [r · R i, j , g · G i, j , b · B(i, j)]

PROBLEM 4. Give some colour. (cont.)

2. Multiply on each image channel for some

constant value (r, g and r are this constant

values). Don’t use any loop.

Page 10: COMPUTER VISION LAB - UAB Barcelona · LAB 0 –PROBLEM 5 The image histogram gives an idea about how the colour/intensity is represented along the image. Is the image dark, is it

LAB 0 – PROBLEM 4

Do this exercise for one of the following

colours: red, green, blue.

And one of the following: magenta, yellow,

and cyan.

PROBLEM 4. Give some colour. (cont.)

3. Concatenate the three channels

using the instruction cat (MATLAB)

4. Save the image generated using

the instruction imwrite (MATLAB /

Octave )

Page 11: COMPUTER VISION LAB - UAB Barcelona · LAB 0 –PROBLEM 5 The image histogram gives an idea about how the colour/intensity is represented along the image. Is the image dark, is it

LAB 0 – PROBLEM 5

The image histogram gives an idea about how the

colour/intensity is represented along the image. Is

the image dark, is it bright, does it have huge

range of grey (kind of flat histogram) or it has only

very few colours (all the values lie almost on the

same bin).

MATLAB / OCTAVE

PROBLEM 5. Compute the image histogram. (+1)

Page 12: COMPUTER VISION LAB - UAB Barcelona · LAB 0 –PROBLEM 5 The image histogram gives an idea about how the colour/intensity is represented along the image. Is the image dark, is it

LAB 0 – PROBLEM 5

Now perform the histogram equalization of the cameraman

image. MATLAB / OCTAVE

The result of the histogram equalization should enhance

the contrast of the image but as you can see with the

cameraman it doesn't almost anything. Just try with one of

the following images:

PROBLEM 5. Compute the image histogram. (cont)

https://dipandcvofgong.files.wordpress.com/2011/08/sat_map3.jpghttps://photofying.files.wordpress.com/2012/11/pict0004.pnghttps://dipandcvofgong.files.wordpress.com/2011/08/t22.jpg

Page 13: COMPUTER VISION LAB - UAB Barcelona · LAB 0 –PROBLEM 5 The image histogram gives an idea about how the colour/intensity is represented along the image. Is the image dark, is it

LAB 0 – PROBLEM 6

One of the widest computer techniques is the OCR

(Optical Character Recognition). It converts a text on an

image to digital text.

We won’t perform this technique in this Lab but be will do

a first step, text segmentation. Then, forget about the

image and just try to remove this kind of yellowish

background without loosing the text.

If you want to perform the complete OCR process try this

online resource: http://www.onlineocr.net/

PROBLEM 6. Thresholding. (+3)

Page 14: COMPUTER VISION LAB - UAB Barcelona · LAB 0 –PROBLEM 5 The image histogram gives an idea about how the colour/intensity is represented along the image. Is the image dark, is it

Using the following references, test 5 different

values.

Then, plot the original image and the results

using a subplot of 2x3 using titles specifying

the used threshold value

MATLAB / OCTAVE

LAB 0 – PROBLEM 6

PROBLEM 6. Thresholding. (cont)

Page 15: COMPUTER VISION LAB - UAB Barcelona · LAB 0 –PROBLEM 5 The image histogram gives an idea about how the colour/intensity is represented along the image. Is the image dark, is it

DELIVERABLES CERBERO

What you have to deliver:

1. Code:Lab0.m

Zip it all together and name it NIULab0.zip

What NOT to deliver

1. The mandatory image sources folder

Deadline: Th. Feb. 23th. 23:00h. (Cerbero)

Page 16: COMPUTER VISION LAB - UAB Barcelona · LAB 0 –PROBLEM 5 The image histogram gives an idea about how the colour/intensity is represented along the image. Is the image dark, is it

DEAR CLASS

IF YOU HAVE ANY QUESTIONDON’T HESITATE TO CONTACT ME

[email protected]: [CVLab]