0

I have tiff files where I want to remove the even numbered pages. I have read other posts asking for the method in many different languages except for Matlab. How can this be done in Matlab?

Senyokbalgul
  • 1,058
  • 4
  • 13
  • 37
  • 1
    Too broad. Just look at the docs for [reading a page](http://www.mathworks.com/help/matlab/ref/imread.html#inputarg_idx) and [writing multiple pages](http://www.mathworks.com/help/matlab/ref/imwrite.html#input_argument_namevalue_writemode) – Suever Jun 14 '16 at 16:22
  • I did take a look at them but didn't find what I was looking for. – Senyokbalgul Jun 15 '16 at 12:38

1 Answers1

1

The solution for your problem is to read only the relevant tiff pages (i.e. the odd ones) and the save them in a separate file. This can be done as follows:

%defines path to input and output files
inputFileName = '<input file name>';
outFileName = 'out.tiff';

%reads tiff file info
tiffData= imfinfo(inputFileName);

%reads every odd page and append it to the output file
for k = 1:2:numel(tiffData)
currentTiff = imread(inputFileName,k);
imwrite(currentTiff, outFileName, 'writemode', 'append');
end
ibezito
  • 5,782
  • 2
  • 22
  • 46