Compress image with PCM encoder

조회 수: 1 (최근 30일)
Marian-Catalin Pirvulescu
Marian-Catalin Pirvulescu 2020년 2월 24일
답변: Pujitha Narra 2020년 2월 26일
For an equation like x(t) = A*sin(2*pi*f*t) the result is code like this:
% Analog signal
f=2; % Maximum freq of the input signal
fs=5*f;
t=0:1/fs:1;
a=2;
x=a*sin(2*pi*f*t);
% Amplitude shifting
x_pos=x+a;
% Quantization
quant=round(x_pos);
% Decimal to binary
encoder=de2bi(quant, 'left-msb');
% Receiver
decoder=bi2de(encoder,'left-msb');
% Shifting the amplitude back
x_out=decoder-a;
My question is, for a given .PGM image, how can I compress it with a PCM encoder following these steps (analog signal- sampler-quantizer-encoder-decoder) and change its bits per pixel?
  댓글 수: 2
Walter Roberson
Walter Roberson 2020년 2월 24일
The numeric values read in by imread() can already be considered to be quantized. However if you wanted, you could quantize further. For example, you might do
quant = round(TheImage, -1);
which would round uint8 or uint16 values to the nearest 10.
encoder=de2bi(quant, 'left-msb');
For consistency you should be passing in N, the minimum number of digits to use.
Marian-Catalin Pirvulescu
Marian-Catalin Pirvulescu 2020년 2월 24일
Thank you, Walter!
For exemple, if my image is 8 bits per pixel and I want to change it to 5 bits per pixel and keep the .PGM format, how should I write the code?

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

답변 (1개)

Pujitha Narra
Pujitha Narra 2020년 2월 26일
Hi,
This is one of the several submissions in MATLAB File Exchange. Feel free to contact the author of this submission directly for specific questions about the implementation.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by