How can I change a file into a tiff file and save into a specific folder?

2 ビュー (過去 30 日間)
Syeda Tabassum
Syeda Tabassum 2014 年 12 月 15 日
回答済み: Image Analyst 2014 年 12 月 16 日
In the following code I am saving a file, which is 'ROInew' into a specific folder with specified name as you can from 'filename_ROI':
Code:
filename_ROI =['C:\Data\TD205_check_ROI' '\' SFDI_timepoints(timepoints).name '_' mice_data(mice_ind).name '_' tissue_file(tissue_ind).name '_ROI'];
(['Saving ' filename_ROI '...']);
[fid_new, message] = fopen(filename_ROI, 'w+');
ROInew = raw_roi(:,:,1, 3)';
fwrite(fid_new,ROInew,'float');
fclose(fid_new);
figure()
Question: What I want to do is save the ROInew file as a .tiff image into the same folder and with the same name. How can I do that? I used save as , but that does not save into the same folder and with the same name.
Syeda

回答 (2 件)

Chad Greene
Chad Greene 2014 年 12 月 15 日
編集済み: Chad Greene 2014 年 12 月 15 日
Read a png file like this:
A = imread('coins.png');
Write it to tiff like this:
imwrite(A,[filename,'.tiff'],'tiff');

Image Analyst
Image Analyst 2014 年 12 月 16 日
% Construct filename properly
folder = 'C:\Data\TD205_check_ROI';
baseFilename = sprintf('%s_%s_%s_ROI.tif',...
SFDI_timepoints(timepoints).name,...
mice_data(mice_ind).name,...
tissue_file(tissue_ind).name);
fullFileName = fullfile(folder, baseFilename);
% Now write out array with that filename.
imwrite(ROInew, fullFileName);

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by