bpsk image modulaton

조회 수: 6 (최근 30일)
ahmed alshammari
ahmed alshammari 2012년 2월 27일
답변: Tasos Giannoulis 2017년 1월 27일
Hi I am trying to use bpsk to transmitt an image in a problem I am working on but I have a problem with reshaping the image back.
my code
clear all close all imag = imread('saina.jpg');
img= imag(:,:,:);
[z zz t] = size( img);
bin = dec2bin(img, 8); [z zz t] = size( img);
bin = dec2bin(img, 8); %de2bi()has lower resolution%
[s ss] = size(bin);
sigg = reshape( bin', 1,s*ss );
sig = str2num(sigg'); % if no transpose then sig will be Inf%
M = modem.pskmod(2);
sig1 = modulate(M,sig);
z=modem.pskdemod(2); %demodulation object
kr= demodulate(z,sig); %demodulating the data kr1 = (sig+1)/2;
newrsig = reshape(kr', ss , s);
newrsigg= newrsig';
final = bin2dec ( num2str(newrsigg) );
final = reshape ( final', z ,zz , t);
figure, imshow (uint8(final(:,:,:))) ,
after running this code i get the following error messge
??? Error using ==> reshape Conversion to double from modem.pskdemod is not possible.
Error in ==> Untitled4 at 41 final = reshape ( final', z ,zz , t);

답변 (1개)

Tasos Giannoulis
Tasos Giannoulis 2017년 1월 27일
The problem is that you store the image dimensions in a variable called 'z', but then you overwrite this variable 'z' with the demodulator object (modem.pskdemod). Therefore in the RESHAPE call you do not provide your desired dimensions (that were originally stored in 'z'); instead you pass the demodulator object.
The solution is to use a different variable name. Also a good practice would be to use variable names that do not conflict with existing functions (e.g., 'imag').


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

Community Treasure Hunt

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

Start Hunting!

Translated by