-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtiffwrite.m
41 lines (38 loc) · 1.17 KB
/
tiffwrite.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function tiffwrite(A,FileStr,idx)
%% Writting a row*column*N matrix to a stack of tiff image
% ****************************************************************
% tiffwrite(A);
% tiffwrite(A,FileStr);
% tiffwrite(A,FileStr,idx);
% ****************************************************************
% Author:ZYD,IBP,CAS 11/30/2009
% Revise:WY,12/2/2014. Converted the 'imwrite' into 'imwritestack', because
% imwrite always has no permission to write when stack is too large.
if nargin==1
[filename, pathname] = uiputfile( ...
{'*.tif;*.tiff', 'All TIF-Files (*.tif,*.tiff)'; ...
'*.*','All Files (*.*)'}, ...
'Save Image File');
if isequal([filename,pathname],[0,0])
return
else
if isempty(strfind(filename,'.tif'))
filename=strcat(filename,'.tif');
end
FileStr = fullfile(pathname,filename);
end
end
if exist(FileStr,'file')
delete(FileStr);
end
if nargin==3
index=idx;
if length(index)==1
imwritestack(A(:,:,index),FileStr);
else
v=index(1):index(2);
imwritestack(A(:,:,v),FileStr);
end
else
imwritestack(A,FileStr);
end