Hi Abhisek,
Given that you've already read the file into a variable called “rawData” and reshaped it into a matrix “imageData” with 32768 rows and 256 columns, it seems that you might need to further reshape the data to match the actual dimensions of the individual projections.
Here's a step-by-step approach to help you proceed:
- Determine the Number of Projections: You'll need to know how many projections are included in the file. This information is sometimes provided in accompanying metadata files or documentation.
- Reshape the Data: Once you know the number of projections, you can reshape the data into a 3D array where the dimensions correspond to the number of rows and columns of each projection image and the number of projections.
- Extract Individual Projections: After reshaping the data into a 3D array, you can access individual projections by indexing into the array.
Here's how you might modify your code to include these steps:
filepath = '/Volumes/Elements/rawDataSet/2023-12-07_144401_ST2/2023-12-07_144401_ST2_XST_CTnoContrast1bed38mm_v1_OSEM_DS4_Slight.ct.img';
fid = fopen(filepath, 'rb');
rawData = fread(fid, inf, 'single');
imageData = reshape(rawData, [numRows, numCols, numProjections]);
firstProjection = imageData(:, :, 1);
imagesc(firstProjection);
projection = imageData(:, :, i);
imwrite(uint8(projection), sprintf('projection_%03d.png', i));
Please note that the number of projections (numProjections) we have mentioned assumes that size of each projection is 256*256. If this is not correct, you will need to find the correct value based on the file's documentation or metadata. Also, the uint8 conversion is used for saving the images. If your data has a higher dynamic range, you might need to use a different data type such as uint16 or adjust the scaling accordingly.
For more information on the "imagesc" and "imwrite" functions, refer to the MATLAB documentation:
Hope this helps!