Skip to content

Commit 17af51b

Browse files
authored
Create HaarWavelet.m
1 parent d1af793 commit 17af51b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Transformation/ HaarWavelet.m

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
% haar_transform:
2+
% Given an input greyscale image of 256 levels, apply the haar transform to it.
3+
% Will apply the transform first to the rows and then to the columns
4+
function haar_matrix = haar_transform(original_matrix)
5+
temp_matrix = haar_pass(original_matrix);
6+
temp_matrix = transpose(temp_matrix);
7+
temp_matrix = haar_pass(temp_matrix);
8+
haar_matrix = transpose(temp_matrix);
9+
end
10+
11+
function haar_matrix = haar_pass(matrix)
12+
haar_matrix = zeros(size(matrix,1),size(matrix,2));
13+
half_col = size(matrix,2)/2;
14+
for row = 1:size(matrix,1)
15+
i = 1;
16+
for col = 1:2:size(matrix,2)
17+
haar_matrix(row,i) = (matrix(row,col)+matrix(row,col+1))/2;
18+
haar_matrix(row,i+half_col) = matrix(row,col) - matrix(row,col+1);
19+
i = i + 1;
20+
end
21+
end
22+
end

0 commit comments

Comments
 (0)