MATLAB显示串口接收的rgb565图像
来源:互联网 发布:linux启动卡在进度条 编辑:程序博客网 时间:2024/05/16 12:19
程序一(感觉有问题):
clc
clear all;
close all;
a=textread('C:\Users\Administrator\Desktop\11.txt','%s')';%以字符形式打开文件
Images_Dec=hex2dec(a)'; %16进制转化为10进制数,存入Images_Dec矩阵
i=1;j=0;str=[];
while i<=length(Images_Dec)
j=j+1;
str(j)=Images_Dec(i+1)+Images_Dec(i)*256;
i=i+2;
end
A=zeros(320,240);
pic=uint8(zeros(320,240,3));
for i=1:320
for j=1:240
A(i,j)=str((i-1)*240+j);
pic(i,j,1)=uint8(bitshift(A(i,j),-11));
pic(i,j,2)=uint8(bitshift(A(i,j),-5));
pic(i,j,3)=uint8(bitshift(A(i,j),0));
end
end
R = bitshift(bitand(A,63488),-8); %# Red component
G = bitshift(bitand(A,2016),-3); %# Green component
B = bitshift(bitand(A,31),3); %# Blue component
im888 = cat(3,R,G,B);
r=R*(31/255);
g=G*(63/255);
b=B*(31/255);
RGB565 = cat(3,r,g,b); %# Concatenate along the third dimension
figure(1);
imshow(RGB565);
figure(2);
imshow(im888);
figure(3);
imshow(pic);
程序二(能显示,不正常):
clc
clear all;
close all;
length=240;width=320;
in_name='C:\Users\Administrator\Desktop\44.txt';
out_name='C:\Users\Administrator\Desktop\dd.bmp';
pic=uint8(zeros(length,width,3));
in=textread(in_name,'%s');
dec_data=hex2dec(in);
% dlmwrite('dec.txt',dec_data,'','');
% dec_test=dec_data(1:320);
k=1;
for i=1:length
for j=1:width
H=dec_data(k,1);
if(k+1>width*length*2)
k=k-1;
else
k=k;
end
L=dec_data(k+1,1);
k=k+2;
pic(i,j,1)=(H/8)*8;
pic(i,j,2)=(mod(H,8)*8+L/32)*4;
pic(i,j,3)=(mod(L,32))*8;
end
end
figure,imshow(pic);
imwrite(pic,out_name);
弄了一天都没完全解决问题。。。。。
我的串口发送部分为:
for(i=0;i<240;i++)
{
for(j=0;j<320;j++)
{
while(USART_GetFlagStatus(USART1,USART_FLAG_TXE)==RESET);//循环发送,直到发送完毕
USART_SendData(USART1,rgb_buf[i][j]%256);
while(USART_GetFlagStatus(USART1,USART_FLAG_TXE)==RESET);//循环发送,直到发送完毕
USART_SendData(USART1,rgb_buf[i][j]/256);
}
}
- MATLAB显示串口接收的rgb565图像
- android显示RGB565数据图像
- Matlab处理彩色图像 RGB888-RGB565
- Matlab图像的显示
- Matlab接收串口数据
- Matlab接收串口数据
- MATLAB利用串口接收数据,并实时显示图形
- RGB565、RGB555、RGB888图像DIB显示
- RGB565、RGB555、RGB888图像DIB显示
- matlab 图像的扫描显示
- matlab 图像的渐进显示
- matlab 图像颜色的显示
- 串口接收ov7620灰度值并在pc上显示图像vc6.0编程
- 《Qt串口通信》--实时显示接收的数据
- MATLAB中图像的显示问题(imshow)
- 模拟Matlab显示图像的效果
- matlab rgb通道的图像显示
- matlab显示图像的函数imshow
- STL各种容器的使用总结
- android webView 全屏播放网络视频
- 基础博弈论之——简单的博弈问题【hdu1525】【Euclid‘s Game】
- 常见添加剂list
- 来自这里http://www.imooc.com/qadetail/149581?t=198457
- MATLAB显示串口接收的rgb565图像
- java中Logger.getLogger(Test.class)
- 文件操作时的问题
- 集合中按照商品价格排序,按照学生编号排序,Collections集合里的sort方法,Comparator<T>接口,Comparable<T>接口,
- Java学习 线程
- 视频内容谁来保护?阿里云视频加密技术大揭秘,打造云上视频安全体系
- Android开发中自定义按钮的形状
- webpack2 实战截图+注释
- 思想决定高度