matlab读取RGB888或RGB565像素文件并绘图
来源:互联网 发布:淘宝订单怎么取消订单 编辑:程序博客网 时间:2024/06/05 17:22
1、matlab下,通过读取txt文件中的RGB888格式的像素文件绘图,并将其转换为RGB565格式后再绘图。代码如下:
clear all;
close all;
a=textread('E:\matlab\rst.txt','%6s')';%以字符形式打开文件
Images_Dec=hex2dec(a)'; %16进制转化为10进制数,存入Images_Dec矩阵
for i=1:576
for j=1:1440
for k=1:3
A(i,j,k)=Images_Dec((i-1)*1440*3+(j-1)*3+k);
end
end
end
fr=A(:,:,1);
fg=A(:,:,2);
fb=A(:,:,3);
ar=fr*(31/255);
ag=fg*(63/255);
ab=fb*(31/255);
imgRGB565 = cat(3,ar,ag,ab); %# Concatenate along the third dimension
%imwrite(imgRGB565,'myImage.bmp'); %# Output the image to a file
subplot(2,1,1);
imshow(A);
subplot(2,1,2);
imshow(imgRGB565);
rst.txt中文件内容如下图所示:
2、matlab下,通过读取txt文件中的RGB565格式的像素文件,从中解析出RGB888像素后绘图,并将其转换为RGB565格式后再绘图。代码如下:
clear all;
close all;
a=textread('E:\matlab\a.txt','%4s')';%以字符形式打开文件
Images_Dec=hex2dec(a)'; %16进制转化为10进制数,存入Images_Dec矩阵
A=zeros(576,720);
for i=1:576
for j=1:720
A(i,j)=Images_Dec((i-1)*720+j);
end
end
imgR = bitshift(bitand(A,63488),-8); %# Red component
imgG = bitshift(bitand(A,2016),-3); %# Green component
imgB = bitshift(bitand(A,31),3); %# Blue component
im888 = cat(3,imgR,imgG,imgB);
ar=imgR*(31/255);
ag=imgG*(63/255);
ab=imgB*(31/255);
imgRGB565 = cat(3,ar,ag,ab); %# Concatenate along the third dimension
subplot(2,1,1);
imshow(imgRGB565);
subplot(2,1,2);
imshow(im888);
a.txt中文件的内容如下:
- matlab读取RGB888或RGB565像素文件并绘图
- Matlab处理彩色图像 RGB888-RGB565
- RGB565 & RGB888
- RGB888->RGB565
- RGB888->RGB565
- RGB888->RGB565
- RGB565,RGB888
- RGB888->RGB565
- RGB888->RGB565->RGB888
- matlab读取txt文件里面的内容并绘图
- RGB888转RGB565
- RGB888 和 RGB565
- RGB888转RGB565
- RGB888转RGB565
- RGB888转RGB565
- RGB888转RGB565
- RGB565转RGB888
- RGB888转RGB565
- win7下配置IIS以及错误模块“ManagedPipelineHandler”解决方法
- mybatis 中 foreach collection的值
- centos下的vi编辑器的使用
- 怎样学好php
- 旋转矩阵推导
- matlab读取RGB888或RGB565像素文件并绘图
- 一次性关闭所有的activity
- linux中某个端口拒绝远程主机连接原因及解决方法
- TCP的四种定时器
- 分布式数据库架构--分库、分表、排序、分页、分组、实现
- windows下maven的环境变量配置
- <context:spring-configured/> 的作用
- 创建screen
- h3viewer 集成 到 vs2010中去