imwrite2

PURPOSE ^

Similar to imwrite, except follows a strict naming convention.

SYNOPSIS ^

function I = imwrite2( I, mulFlag, imagei, path,name, ext, nDigits, nSplits, spliti, varargin )

DESCRIPTION ^

 Similar to imwrite, except follows a strict naming convention.

 Wrapper for imwrite that writes file to the filename:
  fName = [path name int2str2(i,nDigits) '.' ext];
 Using imwrite:
  imwrite( I, fName, writePrms )
 If I represents a stack of images, the ith image is written to:
  fNamei = [path name int2str2(i+imagei-1,nDigits) '.' ext];
 If I=[], then imwrite2 will attempt to read images from disk instead.
 If dir spec. by 'path' does not exist, imwrite2 attempts to create it.

 mulFlag controls how I is interpreted.  If mulFlag==0, then I is
 intrepreted as a single image, otherwise I is interpreted as a stack of
 images, where I(:,:,...,j) represents the jth image (see fevalArrays for
 more info).

 If nSplits>1, writes/reads images into/from multiple directories. This is
 useful since certain OS handle very large directories (of say >20K
 images) rather poorly (I'm talking to you Bill).  Thus, can take 100K
 images, and write into 5 separate dirs, then read them back in.

 USAGE
   I = imwrite2( I, mulFlag, imagei, path, ...
     [name], [ext], [nDigits], [nSplits], [spliti], [varargin] )

 INPUTS
  I           - image or array or cell of images (if [] reads else writes)
  mulFlag     - set to 1 if I represents a stack of images
  imagei      - first image number
  path        - directory where images are
  name        - ['I'] base name of images
  ext         - ['png'] extension of image
  nDigits     - [5] number of digits for filename index
  nSplits     - [1] number of dirs to break data into
  spliti      - [0] first split (dir) number
  writePrms   - [varargin] parameters to imwrite

 OUTPUTS
  I           - image or images (read from disk if input I=[])

 EXAMPLE
  load images; I=images(:,:,1:10); clear IDXi IDXv t video videos images;
  imwrite2( I(:,:,1), 0, 0, 'rats/', 'rats', 'png', 5 );   % write 1
  imwrite2( I, 1, 0, 'rats/', 'rats', 'png', 5 );          % write 5
  I2 = imwrite2( [], 1, 0, 'rats/', 'rats', 'png', 5 );    % read 5
  I3 = fevalImages(@(x) x,{},'rats/','rats','png',0,4,5);  % read 5

 EXAMPLE - multiple splits
  load images; I=images(:,:,1:10); clear IDXi IDXv t video videos images;
  imwrite2( I, 1, 0, 'rats', 'rats', 'png', 5, 2, 0 );      % write 10
  I2=imwrite2( [], 1, 0, 'rats', 'rats', 'png', 5, 2, 0 );  % read 10

 See also FEVALIMAGES, FEVALARRAYS

 Piotr's Computer Vision Matlab Toolbox      Version 2.30
 Copyright 2014 Piotr Dollar.  [pdollar-at-gmail.com]
 Licensed under the Simplified BSD License [see external/bsd.txt]

Generated by m2html © 2003