필터 지우기
필터 지우기

Queries on Quantization input

조회 수: 1 (최근 30일)
Derick Wong
Derick Wong 2013년 12월 31일
편집: Derick Wong 2014년 1월 1일
Does anyone understand the input of this code ? does the vect represent a matrix and how do i determine the input for bits?
function [levelNumbers,scaling] = quantization(vect,bits)
%...'levelNumbers' contains the index of the quantization value
%...'scaling' contains 2 values, the lowest quant. value and delta
[M,N] = size(vect);
if (M>1)
vect = vect';
end
range = max(vect)-min(vect);
delta = roundVal(range/2^(bits));
levels = 2^bits;
base = roundVal(min(vect));
%quantValues = [base : delta : roundVal(max(vect)-delta)]' + delta/2;
quantValues = [base : delta : roundVal(max(vect)-delta)]';
inputArray = repmat(vect , length(quantValues), 1 );
quantArray = repmat(quantValues, 1 , length(vect));
quantDiff = abs(inputArray-quantArray);
[Y,I] = min(quantDiff);
quantResults=quantArray(I);
for i=1:length(quantResults)
levelNumbers(i) = find(quantResults(i)==quantValues);
end
scaling = [base, delta];
if length(quantResults)==0
levelNumbers=ones(1,length(vect));
end
function newVal = roundVal(num)
num = num*1e4;
num = round(num);
newVal = num*1e-4;

답변 (1개)

Walter Roberson
Walter Roberson 2013년 12월 31일
The vect must be a vector, but it can be row order or column order.
The number of bits would be as appropriate for your purposes. 1 bit if you want 2 quantization levels, 2 bits if you want 4 levels, 3 bits if you want 8 levels, and so on.
  댓글 수: 3
Walter Roberson
Walter Roberson 2013년 12월 31일
You can reshape() your matrix into a vector before passing it in.
The number of levels you need is not directly related to the matrix; it is based upon your purpose in quantizing. Which you have not happened to mention
Derick Wong
Derick Wong 2014년 1월 1일
편집: Derick Wong 2014년 1월 1일
My purpose is to do compression. I had to do a compression by going through DCT(discrete cosine transformation) follow by quantization. I have a matrix of
[x1 x2 x3 x4 ... xm
y1 y2 y3 y4 ... ym
z1 z2 z3 z4 ... zm]
In fact there are n rows as well. Initially I used round() as a form of quantization , but now I need to do a inverse quantization which needed me to use this quantization code and another inverse quantization code.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by