![]() |
在Matlab中用RGB数据绘制图像
我有一个包含图像的RGB数据的文本文件,如何在Matlab中使用此数据绘制图像?
数据样本: [INDENT]红色绿色蓝色 80 97 117 83100120 74 91 111 81 96 115 81 96 115 77 90 107 84 97 114 78 91 108 79 95 110 91104120 94108121 85 99112 [/INDENT]回答: [URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/image.html"]IMAGE[/URL]命令采用MxNx3矩阵并将其显示为RGB图像。您可以使用[URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/load.html"]LOAD[/URL]和[URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/reshape.html"]RESHAPE[/URL]将数据转换为正确的格式。最后,IMAGE希望使用0到255之间的整数或0到1.0之间的整数,因此您需要转换或重新缩放数字。以下代码段将向您展示如何将它们组合在一起。 x = load('rgbdata.txt'); % makes a 12x3 matrix x = reshape(x, 2, 6, 3); % reshape pulls columnwise, assume 6x2 image x = x/255; %scale the data to be between 0 and 1 image(x); [url=https://stackoverflow.com/questions/1800472]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 01:10。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.