How can I transmit JPG file within in 8bit array for visible light communication

1 次查看(过去 30 天)
I tried some progarm. but thre is some issue. How can I fix it? i need to transmit an image.
i=imread('Image.jpg');
R = i(:,:,1); %red
G = i(:,:,2); %green
B = i(:,:,3); %blue
for i=1:183
for j=1:275
R(i,j);
bin_Str = dec2bin(R(i,j));
C = reshape(bin_Str',1,numel(bin_Str));
D = reshape(C,size(bin_Str,2),size(bin_Str,1));
  2 个评论
Walter Roberson
Walter Roberson 2021-12-10
What is the point of your C and D? . For example intensity 13, dec2bin would be '1101'. Transpose gives
'1'
'1'
'0'
'1'
reshaping that to 1 row gives '1101' again, exactly what you already had. size('1101',2) is 4, and it has 1 row so D is reshape('1101',4,1) which gives the column vector again. What is the point??
Thakshila Dayani
Thakshila Dayani 2021-12-10
I havent idia about it. but I tried above code. I need to transmit image in led driver. and also the reciving part. how can i do it the best?

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2021-12-11
filename = 'flamingos.jpg';
img = imread(filename);
bitstream = reshape((dec2bin(img(:), 8) - '0').', 1, []);
reconstructed = uint8( reshape(bin2dec(reshape(char(bitstream + '0'), 8, []).'), size(img)) );
imshow(img);
title('original');
imshow(reconstructed);
title('reconstructed');
  7 个评论
Walter Roberson
Walter Roberson 2022-1-31
I would make the same recommendation for Arduino as for Raspberry Pi: send the entire bytes over the link, and have the destination break out the bits for transmission purpose. Write a bit of C or C++ code that will execute on the destination.

请先登录,再进行评论。

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by