Write a Matlab code for the following: 1. Load image ‘Balloon.tif’ and convert i
ID: 3818379 • Letter: W
Question
Write a Matlab code for the following:
1. Load image ‘Balloon.tif’ and convert it into a grayscale image, denoted with ‘img1’
2. Decompose img1 with wavelet transform using function wavedec2 (you can decide the number of decomposition level). Display the wavelet coefficients as an image. Note: you will need to rescale the values to be in the range of [0 255]; otherwise, the image appears black.
3. Reconstruct the edge map from the detail subbands using function waverec2. Hint: set the approximation subband to zero. Save the reconstructed edge map into an image.
4. Using morphology operator to remove the minor edge segments and reduce the width of the edges to one pixel size. Save the result image.
5. Compute the energy, entropy, and homogeneity features for both processed edge maps and calculated the differences.
Explanation / Answer
%An image is displayed after every operation
I = imread('Balloon.tif');
figure();
imshow(I);
img1 = rgb2gray(I);
figure();
imshow(img1);
[C, S] = wavedec2(img1, 1, 'haar');
[H1,V1,D1] = detcoef2('all',C,S,1);
A1 = appcoef2(C,S,'haar',1);
V1img = wcodemat(V1,255,'mat',1);
H1img = wcodemat(H1,255,'mat',1);
D1img = wcodemat(D1,255,'mat',1);
A1img = wcodemat(A1,255,'mat',1);
subplot(2,2,1);
imagesc(A1img);
colormap pink(255);
title('Approximation Coef. of Level 1');
subplot(2,2,2);
imagesc(H1img);
title('Horizontal detail Coef. of Level 1');
subplot(2,2,3);
imagesc(V1img);
title('Vertical detail Coef. of Level 1');
subplot(2,2,4);
imagesc(D1img);
title('Diagonal detail Coef. of Level 1')
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.