Colours inverted in a simulated transmitted image

3 ビュー (過去 30 日間)
Liam
Liam 2024 年 7 月 4 日
回答済み: Umar 2024 年 7 月 4 日
As part of a project, an image was simulated to be transmitted with QPSK modulation, demodulation as well as being passed through an AWGN channel. No matter the SNR value, the image is returned and appear like that when the colours become inverted on an iphone, How do I resolve this issue to get an image similar to the original image? The images can be seen attached.
Original above
Image Passed through the AWGN Channel with an SNR of 4
The code for this is as follows:
P = [16 17 22 24 9 3 14 -1 4 2 7 -1 26 -1 2 -1 21 -1 1 0 -1 -1 -1 -1
25 12 12 3 3 26 6 21 -1 15 22 -1 15 -1 4 -1 -1 16 -1 0 0 -1 -1 -1
25 18 26 16 22 23 9 -1 0 -1 4 -1 4 -1 8 23 11 -1 -1 -1 0 0 -1 -1
9 7 0 1 17 -1 -1 7 3 -1 3 23 -1 16 -1 -1 21 -1 0 -1 -1 0 0 -1
24 5 26 7 1 -1 -1 15 24 15 -1 8 -1 13 -1 13 -1 11 -1 -1 -1 -1 0 0
2 2 19 14 24 1 15 19 -1 21 -1 2 -1 24 -1 3 -1 2 1 -1 -1 -1 -1 0];
blockSize = 27;
pcmatrix = ldpcQuasiCyclicMatrix(blockSize,P);
%Create LDPC encoder and decoder configuration objects, displaying their properties.
cfgLDPCEnc = ldpcEncoderConfig(pcmatrix); %configures LDPC Encoder
cfgLDPCDec = ldpcDecoderConfig(pcmatrix); % configures
M = 4;
snr = 4; % change to SNR Values
numFrames = 10;
ber = comm.ErrorRate;
Imagein = imread("Test.jpg");
[m,n,p]=size(Imagein);
b_array = de2bi(Imagein);
n1=numel(b_array);
data = reshape(b_array,1,n1);
r=mod(n1,486);
z = 486-r;
data2=[data zeros(1,z)];
n2=numel(data2);
n3=n2/486;
infoBits=reshape(data2,486,n3);
data3=int8(infoBits);
encodedData = ldpcEncode(data3,cfgLDPCEnc);
txSig = pskmod(encodedData,M);
rxSig = awgn(txSig,snr);
demod_rxSig = pskdemod(rxSig, M);
decodedData = ldpcDecode(demod_rxSig, cfgLDPCDec, numFrames);
decodedData = decodedData(:);
decodedVec = decodedData(1:n1);
decodedbi_array = reshape(decodedVec,2359296,8);
decoded_decarray = bi2de(decodedbi_array);
reconstructed_image = reshape(decoded_decarray,768,1024,3);
reconstructed_image = uint8(reconstructed_image);
figure ('Name','Original Image')
imshow(Imagein)
figure ('Name', 'Reconstructed Image following transmission through AWGN Channel')
imshow(reconstructed_image)
Is the Image meant to look like this or is it meant to look like that of the original with a few errors if present?

採用された回答

Umar
Umar 2024 年 7 月 4 日
Hi Liam,
The cause of the issue is that the code does not account for the color inversion that occurs during the transmission through the AWGN channel. As a result, the reconstructed image appears inverted on an iPhone. So, to obtain an image similar to the original, you need to correct the color inversion in the reconstructed image. You can achieve this by applying a color inversion transformation to the reconstructed image.Here's the updated code with the color inversion correction:
% ... (your previous code)
reconstructed_image = reshape(decoded_decarray, 768, 1024, 3); reconstructed_image = uint8(reconstructed_image);
% Apply color inversion correction reconstructed_image = 255 - reconstructed_image;
figure('Name', 'Original Image') imshow(Imagein) figure('Name', 'Reconstructed Image following transmission through AWGN Channel') imshow(reconstructed_image)
By subtracting each pixel value from 255, you invert the colors of the reconstructed image, correcting the inversion caused by the AWGN channel.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeQPSK についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by