File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments