function f = RodImg

% Import data from an external file
while 1
   filename = input('Open data file (*.txt): ','s');
   fid=fopen(filename,'rt');
   if fid~=-1		%if filename exists, the loop ends. Otherwise input is required once more.
      break;
   end
	disp('Warning: the file does not exist in the indicated directory! Please input again.');
end

Data0 = fscanf(fid,'%g',[6,inf]);
Data0 = Data0';

[DataCount,width]=size(Data0);
fclose(fid);

DataCount
width
step = Data0(2, 1) - Data0(1, 1)
xcells = max(Data0(:, 1)) / step + 1
ycells = max(Data0(:, 2)) / step + 1

RGBColors = zeros(xcells, ycells, 3);

int32 x; 
int32 y;
for i = 1 : DataCount
    
    x = Data0(i, 1) / step + 1;
    y = Data0(i, 2) / step + 1;
    Color(y, x, 1 : 3) = (Data0(i, 3 : 5) + 0.75 ) ./ 1.5;
    
end

image(Color); 
axis equal;
