⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tiffwrite.m

📁 有关matlab的电子书籍有一定的帮助希望有用
💻 M
字号:
function status = tiffwrite(arg1, arg2, arg3, arg4, arg5)
%TIFFWRITE Write a TIFF (Tagged Image File Format) file to disk.
%   Note: TIFFWRITE has been grandfathered; use IMWRITE instead.
%
%   TIFFWRITE(R,G,B,'filename') writes a TIFF file containing the RGB
%   image in the matrices R,G,B to a disk file called 'filename'.
%
%   TIFFWRITE(X,MAP,'filename') writes a TIFF file containing the
%   indexed image X and colormap MAP to a file called 'filename'.
%   Depending on the number of colors in MAP, TIFFWRITE creates a
%   8-bit or 4-bit TIFF file.  
%
%   TIFFWRITE(I,'filename') writes a TIFF file containing the
%   intensity image I to a file called 'filename'.  Intensity
%   images are written to the file as 8-bit indexed images
%   with a GRAY(256) colormap.  Binary images are written to 
%   the file as 1-bit indexed images with a GRAY(2) colormap.
%
%   TIFFWRITE(...,'compress_flag') permits control over compression.
%   'compress' forces TIFFWRITE to write a compressed TIFF file.
%   'nocompress' forces TIFFWRITE to write an uncompressed TIFF file.
%   'auto' tells tiffwrite to determine whether or not to compress
%   the image. The default is 'nocompress'.
%
%   The extension '.tif' will be added to 'filename' if it 
%   doesn't already have an extension.
%
%   TIFFWRITE is a baseline TIFF writer except that it doesn't
%   support CCITT compression.  TIFFWRITE can write only 
%   uncompressed and packbits compressed files.  LZW compression
%   is not supported.
%
%   See also IMFINFO, IMREAD, IMWRITE.

%   updated to call IMWRITE, Chris Griffin 8-15-96
%   Copyright 1993-1998 The MathWorks, Inc.  All Rights Reserved.
%   $Revision: 5.6 $  $Date: 1997/11/24 15:36:30 $

if nargin < 2, 
    error('Not enough input arguments.');
elseif nargin==2, % tiffwrite(I,'filename')
    if ~isstr(arg2), error('Filename must be a string.'); end
    % gray scale
    filename = arg2;
    if isempty(findstr(filename,'.')), filename=[filename,'.tif']; end
    imwrite(arg1, filename, 'tif', 'compression', 'none');
    
elseif nargin==3
    if ~isstr(arg2),
        if size(arg2,2)~=3, error('Colormaps must be N-by-3.'); end
        % tiffwrite(A,CM,'filename') - palette color
        filename = arg3;
        if isempty(findstr(filename,'.')), filename=[filename,'.tif']; end
        imwrite(arg1, arg2, filename, 'tif', 'compression', 'none');
    else
        % tiffwrite(I,'filename','compress_flag') - gray scale
        filename = arg2;
        if isempty(findstr(filename,'.')), filename=[filename,'.tif']; end
        if isstr(arg3)
            switch lower(arg3)
            case 'compress',
                imwrite(arg1, filename, 'tif', 'compression', 'packbits');
            case 'nocompress',
                imwrite(arg1, filename, 'tif', 'compression', 'none');
            case 'auto',
                imwrite(arg1, filename, 'tif', 'compression', 'none');
            otherwise,
                imwrite(arg1, filename, 'tif', 'compression', 'none');
            end
        else
            error('Invalid input parameters.');
        end
    end
elseif nargin==4
    if isstr(arg3) == 0
        % tiffwrite(R,G,B,'filename') - rgb full color
        RGB(:,:,1) = arg1;
        RGB(:,:,2) = arg2;
        RGB(:,:,3) = arg3;
        filename = arg4;
        if isempty(findstr(filename,'.')), filename=[filename,'.tif']; end
        imwrite(RGB, filename, 'tif','compression', 'none');
    else
        % tiffwrite(A,CM,'filename','compress_flag') - palette color
        filename = arg3;
        if isempty(findstr(filename,'.')), filename=[filename,'.tif']; end
        imwrite(arg1,arg2,filename,'tif','compression','packbits');
  end
elseif nargin==5, % tiffwrite(R,G,B,'filename,'compress_flag')
    RGB(:,:,1) = arg1;
    RGB(:,:,2) = arg2;
    RGB(:,:,3) = arg3;
    filename = arg4;
    if isempty(findstr(filename,'.')), filename=[filename,'.tif']; end
    imwrite(RGB, filename, 'tif', 'compression', 'packbits');
else
    error('Too many arguments.');
end







⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -