Skip to content

Commit d1af793

Browse files
authored
Create dequantization.m
1 parent 4401e26 commit d1af793

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Quantization/dequantization.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
% dequantize_matrix:
2+
% Uniformly projects a matrix with a number of levels (2^old_bytesize)
3+
% into a new matrix with a number of levels (2^new_bytesize)
4+
function dequantized_matrix = dequantize_matrix(matrix, old_bytesize, new_bytesize)
5+
avg_point = 2^(new_bytesize-old_bytesize-1);
6+
dequantized_matrix = zeros(size(matrix,1),size(matrix,2),'uint8');
7+
for row = 1:size(matrix,1)
8+
for col = 1:size(matrix,2)
9+
dequantized_matrix(row,col) = dequantize(matrix(row,col), avg_point);
10+
end
11+
end
12+
13+
function dequantization = dequantize(pixel, avg_point)
14+
dequantization= avg_point*(pixel + 1);
15+
end

0 commit comments

Comments
 (0)