Hi,
I have 20 images that are being stacked (512x512x20) where all the information is in gray scale intensities, and I want the actual data saved into a .mat file. But the file it should be writing into is blank (absolutely no text or numbers). How can I accomplish this as this is pre-processing for a different program? My input file format is a 262144×2 matrix, where I only want the second column of information. I know the stack is being created correctly because I can use the implay function ( implay(ImageStack) ) and see the images.
The file written is as follows (after several prompts of FileSave, i, and j):
ImageStack = zeros(512,512,j-i); %%initiates image stack
FS = fopen(FileSave,'a+'); %%open file for writing
for k = i:j FileName = ['BC_' num2str(k) '_1.txt']; %%open textfile
A = load (FileName); %%load file to matrix A
B = A(:,2); %%Takes only one column from Matrix A into Matrix B
C = reshape(B,512,512)'; %%reshapes Matrix B (262144x1) to Matrix C (512x512)
I = mat2gray(C); %%converts pixel intensity to grays cale (0-1)
ImageStack(:,:,k) = I; %%places image into to stack
fwrite(FS,ImageStack); %%saves file for reading
end
I've tried the save function, but it only saves the variables (i,j,FileName, etc..) Not the actual data within the files. How do I save the actual data to a .mat file? The file File specified is blank after save; and after using the save function it only returns the variables, not the data. I'm using version R2014a.
Thanks
Best Answer