Input image needs to be modulated and transmitted and finally detected using BPSK.
M = 2; %Modulation order 2 for BPSK
randn('state',200); % initializing the randn() function
imdata = imread('lenna.pgm');
bdata = de2bi(imdata);
sizec = size(bdata,1); % height
sizer = size(bdata,2); % width
nbits = sizec*sizer; % number of bits in the image
msg = double(reshape(bdata,nbits,1));
The following code is meant to modulate the input image and display the demodulated output.The resultant output,when i run the code,I get a blank image.Need help in figuring out what I have missed or where I have gone wrong.
%modulate
txpsk = pskmod(msg,M);
%noise
phasenoise = randn(nbits,1)*0.015;
rxpsk = txpsk.*exp(2i*pi*phasenoise);
%demodulate
recovpsk = pskdemod(rxpsk,M);
reshape1rxpsk = reshape(recovpsk,sizec,sizer);
reshape2rxpsk = bi2de(reshape1rxpsk);
finalout= reshape(reshape2rxpsk,size(imdata,1),size(imdata,2));
imshow(finalout)
A PGM file consists of a sequence of one or more PGM images. Each image has a header structure, containing such information, as width, height e.t.c. After modulation you add a noise to your signal. Therefore, the demodulated signal may contain errors. If this errors corrupts header information of image - this may lead to blank image output. Try to comment lines
%phasenoise = randn(nbits,1)*0.015;
%rxpsk = txpsk.*exp(2i*pi*phasenoise);