How to have the input files labels in the output files
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm cropping some files and I want to keep the labels of the input files in the output files. Any idea to achieve that please.
imgFolderStokes = fullfile('Data/Stokes_Parameters/');
imgStokes = imageDatastore(imgFolderStokes);
numOfImgStokes = length(imgStokes.Files);
for ii = 1:numOfImgStokes
Stokes{ii} = fitsread(imgStokes.Files{ii})
targetSize = [244 234];
r = centerCropWindow2d(size(Stokes{ii}),targetSize);
J = imcrop(Stokes{ii},r);
fitswrite(J,'myfile.fits')
end
0 Kommentare
Antworten (1)
Mathieu NOE
am 19 Jul. 2021
hello
my 2 cents suggestion :
imgFolderStokes = fullfile('Data/Stokes_Parameters/');
imgStokes = imageDatastore(imgFolderStokes);
numOfImgStokes = length(imgStokes.Files);
for ii = 1:numOfImgStokes
input_filename = imgStokes.Files{ii};
Stokes{ii} = fitsread(input_filename)
targetSize = [244 234];
r = centerCropWindow2d(size(Stokes{ii}),targetSize);
J = imcrop(Stokes{ii},r);
% % if input_filename contains a dot plus a 3 letters extension,
% % uncomment this line bellow :
% input_filename = input_filename(1:length(input_filename)-4); % optionnal
fitswrite(J,[input_filename '_out.fits'])
end
7 Kommentare
Walter Roberson
am 22 Jul. 2021
outputdir = fullfile('Output_Fits');
if ~isdir(outputdir); mkdir(outputdir); end
stuff
fitswrite(J, char( fullfile(outputdir, input_file+"_out.fits")))
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!