Lecture 1 - DSP applications course

9
Lecture 1 Dr.Omar Nasr, Oct,24 th , 2015 Topics that was covered: 1- Programs that will be used: For image processing: Octave (similar to MATLAB but open source). OpenCV (image processing Library working with Python, C++ and other languages). GIMP (GNU image processing program) - Projects using Octave will get +1 bonus - Projects using OpenCV library will get +2 bonus points For speech processing: Audacity. An open source software for audio recording and editing 2- Image processing: - Install GIMP and read the Getting Started part of the help - Open a colored image in GIMP - Show the pointer window from Windows->Dockable Dialogs → Pointer - Move around with the mouse on the image, observe the location of the origin of image (upper left corner). Y-coordiate increases when moving the mouse down, X-coordinate increaseing when moving to right - every pixel value consists of 3 values (R,G,B) - The whole image is represented in 3 matrices, one for Red, another for G, 3 rd for B - To see the three different channels, go to Layers toolbox, and go to (channels) - every component(channel, or color) can take values ranging from 0 to 255. For a red pixel, the three components will be (255,0,0). For green (0,255,0) - The size of raw image in bytes = total number of pixels x 3 bytes. Note that because

description

first lecture in the DSP- applications course by Dr.Omar Nasr

Transcript of Lecture 1 - DSP applications course

Page 1: Lecture 1 - DSP applications course

Lecture 1Dr.Omar Nasr, Oct,24 th , 2015

Topics that was covered:

1- Programs that will be used:

For image processing:

Octave (similar to MATLAB but open source). OpenCV (image processing Library working with Python, C++ and other languages). GIMP (GNU image processing program)

- Projects using Octave will get +1 bonus

- Projects using OpenCV library will get +2 bonus points

For speech processing:

Audacity. An open source software for audio recording and editing

2- Image processing:

- Install GIMP and read the Getting Started part of the help

- Open a colored image in GIMP

- Show the pointer window from Windows->Dockable Dialogs → Pointer

- Move around with the mouse on the image, observe the location of the origin of image (upper left corner). Y-coordiate increases when moving the mouse down, X-coordinate increaseing when moving to right

- every pixel value consists of 3 values (R,G,B)

- The whole image is represented in 3 matrices, one for Red, another for G, 3rd for B

- To see the three different channels, go to Layers toolbox, and go to (channels)

- every component(channel, or color) can take values ranging from 0 to 255. For a red pixel, the three components will be (255,0,0). For green (0,255,0)

- The size of raw image in bytes = total number of pixels x 3 bytes. Note that because

Page 2: Lecture 1 - DSP applications course

pixel values range from 0 to 255, it needs one byte to be represented

- You can create an image in Gimp by file->new. Then choose the size of the image.

- Try to make an image will all pixels are red using the bucket fill tool in the toolbox

- Save the image in raw format (file->Export as, and then select file type). Check its size

- Save the image in bmp format, check its size

- Open the two files in a Hex editor and check the file header in the bmp file

- HW: check the format of the file header of the bmp and verify that you see what you expect in the Hex editor

- Save the (red) image in *.jpg format, check the file size. Compare it to the file size of theraw image

- Save another image with the same size but with more details in *.jpg format. Compare its file size with the red image. Note that the more details the image has, the higher the file size. JPEG is a (lossy) compression technique. Will be discussed later during the course

Gray scale image:

- Convert an image from rgb to gray by going to image → mode → gray scale

- Move around with the pointer. Now each pixel is represented with a single value that ranges from 0 to 255. 0 represents black, 255 represents white

Indexed image: ( image → mode → Indexed)

- The color information of the image are quantized. Each image has a “pallet”. A pallet can look like the following

Color index R G B

1 255 0 0

2 0 255 0

3 0 0 255

4 255 255 255In the previous example, the pixels in the image can only have one of 4 colors (R,G,B, white). Possible pixel values are 1,2,3,4. Hence, each pixed can be represented in 2 bits.

Page 3: Lecture 1 - DSP applications course

The image size = bits x (number of pixels) + pallet size

Histogram:

- Histogram shows the number of pixels with different intensity levels. There are different ways to show the histogram in GIMP. you can go to Colors → info → histogram

note: convert the image to gray scale first

- The horizontal axis represents the pixel value

ranging from 0 to 255

- The vertical axis represents the number of pixels

with the corresponding pixel value

Pixel level processing:

- Processing each pixel without any consideration to its neighbors.

- Apply to each pixel value, with an output that depends only on the current pixel value only

- Example: y = 255-x . where x is the pixel value at the original image, and y is the pixel value at the output image

- You can apply different functions using Tools → color tools → curves. Then play with theline that defines the functions. This is called (Histogram transformation) or (intensity level transformation)

Page 4: Lecture 1 - DSP applications course

For example, for the following image and the corresponding mapping function:

You get the following output image, which is the (negative) of the original image

Black and white images

You can convert an image a black and white by setting a certain threshold, above which the pixel value will be white, and below it will be black. This can be done using tools → color tools → threshold

Page 5: Lecture 1 - DSP applications course

By moving the the threshold to the right, more and more pixels are converted to black. When the threshold = 255, all the image will be converted to black

Spatial Processing

- Every pixel at the output image does not only depend on the corresponding pixel at the input image, but also on the neighboring pixels

Page 6: Lecture 1 - DSP applications course

HW: review the principles of convolution in signals and systems course. You should be (very) familiar with them.

Spatial filtering:

check up to page 12 in this lecture: www.coe.utah.edu/~cs4640/slides/Lecture5.pdf

When the window size is kxk and all values = 1/(k^2), the result is a smoothing filtering. It causes the image to be (blurred). As k increases, the image gets (smoother)

In GIMP, Go to Filters → Generic → Convolution matrix. Then design a suitable filter. Observe the effect of increasing and decreasing the size of filter (compare 3x3 vs 5x5). Also try to apply the same filter few times and check the output.

Left image: image before applying a 5x5 smoothing filter, right image after applying the filter

Moving average filter in 1-D signals in Octave:x=ones(1,20);

stem(x)

x(10) = 5

h=1/3*[1,1,1]

stem(x)

y=conv(x,h)

stem(y)

y=conv(x,h)

h=1/5*ones(1,5)

Page 7: Lecture 1 - DSP applications course

Windowing function in Octave:f_img = diag(ones(1,10),0)*50 % diagonal matrix

w = ones(3,3)/9 % windowing function

y=conv2(f_img,w) %blurring of the diagonal line

f_img = zeros(10,10) %a dark image

f_img(5,5)=255 % a white pixel in a black image, as if it is noise

y=conv2(f_img,w) % smoothing window, note what happens to the white pixel

f_img(3:7,3:7)=255 % a white (block) in

y=conv2(f_img,w)

--------------------------------

Audio processing using Audacity:

Topics covered:

- recording a speech signal with a sampling frequency of 44100Hz

- recording a speech signal with a sampling frequency of 8000Hz

- Observe the difference in quality, especially in (unvoiced) consonants like (s)

- What is the maximum frequency that is considered in the speech signal when sampling the speech with 8kHz? What about 44100 Hz? Review Nyquist criteria.

- Check the spectrogram of the speech signal in the two cases (stereo recording)

Page 8: Lecture 1 - DSP applications course
Page 9: Lecture 1 - DSP applications course

Useful Octave commands:

- install the image processing package for octave

http://octave.sourceforge.net/image/

https://www.gnu.org/software/octave/doc/interpreter/Installing-and-Removing-Packages.html

then in the octave prompt, write (pkt load image)

- imread : read an image file (e.g. Im=imread('home.jpg')). It returns 3 dimensional image prepresenting R,G, components

- imshow : show the image

- rgb2gray : convert the image to gray level

- imhist : show the histogram of the image

- conv2 : 2D convolution. Can be used in spatial filtering

check all the functions in the package in this link

http://octave.sourceforge.net/functions_by_package.php

Go to the image package and check the functions. Or go directly to http://octave.sourceforge.net/image/overview.html