Image compression channel not working

조회 수: 1 (최근 30일)
Matt Alvarez
Matt Alvarez 2022년 7월 3일
편집: Walter Roberson 2022년 7월 3일
Hi im working on a image compression code for matlab below is the code
clear all;
% Tx Rx Setup
enc = comm.RSEncoder;
mod = comm.DPSKModulator('BitInput',false);
chan = comm.AWGNChannel(...
'NoiseMethod','Signal to noise ratio (SNR)','SNR',10);
demod = comm.DPSKDemodulator('BitOutput',false);
hDdecec = comm.RSDecoder;
errorRate = comm.ErrorRate('ComputationDelay',3);
%compression
X = dctcompr ("Picturetest.jpg",19200,"OutputPicturetest.jpg")
%Reading and converting to digital data of image (working)
im=imread('OutputPicturetest.jpg');
imshow(im)
pause(1)
IMAGEBIN=im2bw(im,0.4);
imshow(IMAGEBIN);
%channel(not working, incomplete from project specs)
encodedData = step(enc, IMAGEBIN(:,[1]));
modSignal = step(mod, encodedData);
receivedSignal = step(chan, modSignal);
demodSignal = step(demod, receivedSignal);
receivedSymbols = step(hDdecec, demodSignal);
errorStats = step(errorRate, data, receivedSymbols);
%merge decoded column matrices into one
%mask the merged matrix to original image to simulate conversion(working)
maskedImage=uint8(IMAGEBIN).*im;
%show image and save(working)
imshow(maskedImage);
imsave;
The image "Picturetest.jpg" is a 1080p photo from the internet
for compression, i am using a function made by Luigi rosa from file exchange
Currently my code is having problems on the channel part. When i run the code, this error message pops up:
Error using IntegerRSEncoder/step
The input data type must
not be Boolean.
Error in comm.RSEncoder/stepImpl (line 341)
y = step(obj.cIntRSEnc, x);
i would like to ask if there is any way to resolve this issue?
  댓글 수: 2
KALYAN ACHARJYA
KALYAN ACHARJYA 2022년 7월 3일
Have you observed the error -
"The input data type must not be Boolean"
In the code-
IMAGEBIN=im2bw(im,0.4);
Matt Alvarez
Matt Alvarez 2022년 7월 3일
is it possible to convert the image into a format that can be used in the channel part?

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

채택된 답변

Walter Roberson
Walter Roberson 2022년 7월 3일
편집: Walter Roberson 2022년 7월 3일
IMAGEBIN=im2bw(im,0.4);
im2bw returns logical data
encodedData = step(enc, IMAGEBIN(:,[1]));
That kind of encoder does not accept logical by default. When you construct the encoder set BitInput to true

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by