0% found this document useful (0 votes)
152 views13 pages

Digital Image Processing HW2

This document discusses different image filtering and resizing techniques. It shows examples of applying Gaussian, log, and unsharp filters to an image with varying kernel sizes and sigma values. It also demonstrates resizing an image using imresize with nearest, bilinear, and bicubic interpolation, as well as a zero-interleave method with nearest, bilinear, and bicubic interpolation kernels. The conclusion is that directly resizing with imresize produces better results than the zero-interleave method, which causes black dots to appear.

Uploaded by

api-3830691
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
152 views13 pages

Digital Image Processing HW2

This document discusses different image filtering and resizing techniques. It shows examples of applying Gaussian, log, and unsharp filters to an image with varying kernel sizes and sigma values. It also demonstrates resizing an image using imresize with nearest, bilinear, and bicubic interpolation, as well as a zero-interleave method with nearest, bilinear, and bicubic interpolation kernels. The conclusion is that directly resizing with imresize produces better results than the zero-interleave method, which causes black dots to appear.

Uploaded by

api-3830691
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 13

Digital Image Processing HW2

1. a. >> f1=fspecial('gaussian',[5,5],1);
>> figure,surf(1:5,1:5,f1)

0.2

0.15

0.1

0.05

0
5
4 5
3 4
3
2 2
1 1

b. >> f2=fspecial('gaussian',[7,7],2);
>> figure,surf(1:7,1:7,f2),axis tight

0.04

0.03

0.02

0.01

6
7
6
4 5
4
2 3
2
1

49385002 資工三陳俊志
c. >> f3=fspecial('gaussian',[9,9],3);
>> figure,surf(1:9,1:9,f3),axis tight

0.02

0.015

0.01

0.005

8
6 8
6
4
4
2 2

2. 5x5 with σ=1: >> camera=imread('cameraman.tif');


>> figure,imshow(filter2(f1,camera)/256)

7x7 withσ=2: >> figure,imshow(filter2(f2,camera)/256)

49385002 資工三陳俊志
9x9 withσ=3: >> figure,imshow(filter2(f3,camera)/256)

3. a.>> log1=fspecial('log',[5,5]);
>> figure,surf(1:5,1:5,log1),axis tight

49385002 資工三陳俊志
0

­1

­2

­3

­4

5
4 5
3 4
3
2 2
1 1

b. >>log2=fspecial('log',[7,7],1);
>> figure,surf(1:7,1:7,log2),axis tight

­0.05

­0.1

­0.15
­0.2

­0.25
­0.3

6
7
6
4 5
4
2 3
2
1

4. 5x5 withσ=0.5:>> figure,imshow(mat2gray(filter2(log1,camera))/2)

49385002 資工三陳俊志
7x7 withσ=1: >> figure,imshow(mat2gray(filter2(log2,camera))/2)

5. a. >> u1=fspecial('unsharp');
>> figure,imshow(filter2(u1,camera)/255)

49385002 資工三陳俊志
b. >> u2=fspecial('unsharp',0.5);
>> figure,imshow(filter2(u2,camera)/255)

c. >> u3=fspecial('unsharp',1.0);
>> figure,imshow(filter2(u3,camera)/255)

49385002 資工三陳俊志
6. Using imresize:
‘nearest’: >>head1=imresize(head,4);
>>imshow(head1)

49385002 資工三陳俊志
‘bilinear’: >> head2=imresize(head,4,'bilinear');
>> imshow(head2)

49385002 資工三陳俊志
‘bicubic’: >> head3=imresize(head,4,'bicubic');
>> imshow(head3)

49385002 資工三陳俊志
Using the zero interleave method:
‘nearest’: >> headz=zeroint(zeroint(head));
>> imshow(filter2([1 1 0;1 1 0;0 0 0],headz)/255)

49385002 資工三陳俊志
‘bilinear’: >> imshow(filter2([1 2 1;2 4 2;1 2 1]/4,headz)/255)

49385002 資工三陳俊志
‘bicubic’: >> bicub=[1 4 6 4 1;4 16 24 16 4;6 24 36 24 6;4 16 24 16 4;1 4 6 4 1]/64;
>> imshow(filter2(bicub,headz)/255)

49385002 資工三陳俊志
Conclusion: To make the resulting image four times as big as the original, the latter
method will cause the black dots to appear in the images. Judging from the results, I think
the former method is obviously better.

49385002 資工三陳俊志

You might also like