Frage

I have many files (e.g. 100) that contains the intensity of the 512x512 pixels of a CCD camera, each files being at a different light frequency. Those files are formatted like this :

1, 1, 602
1, 2, 598
1, 3, 546

The first number is the Row of the pixel, the second one is the Column of the pixel, and the last one is the Intensity on the pixel.

I'd like to have an array for each of these pixels. Here's my code so far :

%the user selects the "many files"%
filenames = uigetfile('*.csv','','','Multiselect','on');  

%here to know the number of different frequency for each pixel
NumFiles = numel(filenames);  

%There are 512x512 pixels, each with NumFiles different intensities
Pixel = cell(512,512,NumFiles);  

After this part, I'm not quite sure how to proceed. I want the Pixel(1,1,:) to be all the Intensities of my first pixel, these informations being taken from each files.

Marc-Olivier

War es hilfreich?

Lösung

Try this -

%the user selects the "many files"%
filenames = uigetfile('*.csv','','','Multiselect','on');

%here to know the number of different frequency for each pixel
NumFiles = numel(filenames);

%There are 512x512 pixels, each with NumFiles different intensities
Pixel = cell(512,512,NumFiles)
count = 0
num_pixels = size(Pixel,1)*size(Pixel,2)

for k = 1:NumFiles
    fid = fopen(char(filenames(k)));
    C = textscan(fid, '%d, %d, %d')
    Pixel(count + sub2ind(size(Pixel),C{1},C{2})) = num2cell(C{3});
    count = count + num_pixels;
    fclose(fid);
end
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top