bpsk image modulaton

8 ビュー (過去 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);
l=length(sig1);
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 Center および File ExchangeBPSK についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by