how to create image from text file data.?
2 次查看(过去 30 天)
显示 更早的评论
This is the text file i have generated.. I want to create image from it.. It will be binary image..
clc;
clear;
fileID = fopen('patil142.txt');
C = textscan(fileID, '%f32 %f32');
fclose(fileID);
x=cell2mat(C(:,1));
y=cell2mat(C(:,2));
x=x';
y=y';
I am able to read it only but don't know how to create image..?
4 个评论
Walter Roberson
2012-11-22
The text file you linked to has x running 1 to 480, but y in the range 333 to 340, and has no 0's in it. If you are hitting 0 then either there is a problem in the reading or you are reading different data than you linked to.
采纳的回答
Image Analyst
2012-11-22
Try this:
maxRows = max(y);
maxCols = max(x);
binaryImage = false(maxRows, maxCols);
for k = 1 : length(x)
row = int32(y);
col = int32(x);
binaryImage(row, col) = true;
end
14 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!