matlab lecture 4 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Matlab Lecture 4 PowerPoint Presentation
Download Presentation
Matlab Lecture 4

Loading in 2 Seconds...

play fullscreen
1 / 16

Matlab Lecture 4 - PowerPoint PPT Presentation


  • 139 Views
  • Uploaded on

Matlab Lecture 4. Spatial Filtering. Image Types in the Toolbox. The Image Processing Toolbox supports four: Basic types of images: Indexed images RGB images Intensity images Binary images. Colored. Gray-scale. Black and white. Summary of Image Types and Numeric Classes.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Matlab Lecture 4' - beth


Download Now An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
matlab lecture 4

Matlab Lecture 4

Spatial Filtering

image types in the toolbox
Image Types in the Toolbox

The Image Processing Toolbox supports four:

Basic types of images:

  • Indexed images
  • RGB images
  • Intensity images
  • Binary images

Colored

Gray-scale

Black and white

spatial filtering
Spatial Filtering
  • Filtering in Matlab
    • Linear filters:usingfspecial(type,parameter);The type could be:
      • ‘average’ filter
      • ‘laplacian’ filter
      • ‘log’ filter
    • Non-linear filters:
      • Median filter:
        • medfilt2
spatial filtering1
Spatial Filtering
  • We can create our filters by hand, or by using the fspecial function; this has many options which makes for easy creation of many deferent filters.
  • fspecial(type,parameter)  creates and returns common filters.
  • filter2(filter,image)  apply the filter on the image
averaging filtering
Averaging Filtering
  • fspecial('average',[5,7])
    • will return an averaging filter of size 5 x 7
  • fspecial('average',11)
    • will return an averaging filter of size 11 x 11
  • fspecial('average')
    • will return an averaging filter of size 3 x 3 (default)
averaging filtering1
Averaging Filtering
  • For example, suppose we apply the 3 x 3 averaging filter to an image as follows:

>> c=imread('cameraman.tif');

>> f1=fspecial('average');

>> cf1=filter2(f1,c);

  • We now have a matrix of data type double. To display this, we can do any of the following:
    • transform it to a matrix of type uint8, for use with imshow.
      • imshow(uint8(cf1));
    • divide its values by 255 to obtain a matrix with values in the 0.1-1.0 range, for use with imshow.
      • imshow(cf1/255);
    • use mat2gray to scale the result for display.
      • imshow(mat2gray(cf1));

>> figure,imshow(c),figure,imshow(cf1/255)

averaging filtering2
Averaging Filtering
  • will produce the images shown in figures 6.4(a) and 6.4(b).
  • The averaging filter blurs the image; the edges in particular are less distinct than in the original.
  • The image can be further blurred by using an averaging filter of larger size. This is shown in the following figures:
frequencies low and high pass filters
Frequencies; low and high pass Filters
  • High pass filter if it passes over the high frequency components, and reduces or eliminates low frequency components.
  • Low pass filter if it passes over the low frequency components, and reduces or eliminates high frequency components.
  • Both are mainly used for noise reduction, sharpen, or smooth the image.
  • May be used for edge detection.
  • The output may be the same for the tow types.
  • sharp  smooth (low), smooth  sharp (high)
frequencies low and high pass filters1
Frequencies; low and high pass Filters

>> f=fspecial('laplacian');

>> cf=filter2(f,c);

>> imshow(cf/255);

>> f1=fspecial('log');

>> cf1=filter2(f1,c);

>> figure,imshow(cf1/255);

high pass filtering
High Pass Filtering
  • The images are shown in figure 6.5. Image (a) is the result of the Laplacian filter; image (b) shows the result of the Laplacian of Gaussian (log) filter.
median filter
Median Filter
  • medfilt2
  • Median filtering is a nonlinear operation often used in image processing to reduce "salt and pepper" noise.
  • What is "salt and pepper" noise ?
    • it is randomly occurring of white and black pixels.

n = imnoise(i,'salt & pepper‘,0.2);

imshow(n);

The default is 0.05

Higher value  more noise

median filter1
Median Filter
  • B = medfilt2(A) performs median filtering of the matrix A using the default 3-by-3.
  • Examples
    • Add salt and pepper noise to an image and then restore the image using medfilt2.

>>I = imread('eight.tif');

>>J = imnoise(I,'salt & pepper',0.2);

>>K = medfilt2(J);

>>imshow(J), figure, imshow(K)