A method to convert .tif files to .csv files for rapidly accessing pixel values.

11 views (last 30 days)
I am proceesing data from 35,000 tif files, 96 at a time. Reading 96 .tif files into RAM (650 1500 pixels each) is very slow, and quickly bogs down (memory leak?). A simpler way to go seems to be to extract the pixel values individually from the files (using csvread(filename,row,column,range)), which avoids cramming the files into memory. Is there a quick way to convert .tif to .csv files? Alternatively, is there a simple way to acess specific pixels from a tif without reading the file inot memory?
  4 Comments
dpb
dpb on 13 Aug 2014
Well, 96 images are almost 90 MB if they're 8-bit or less; otherwise multiply by the number of bytes required/pixel (3 for 24-bit, for example).
Storing a 16-bit ASCII representation of a 24-bit number will expand that to being 8-bytes/pixel to represent all values--hardly a memory tradeoff.
And, what is "extract the pixel values individually from the files.." other than reading into memory? How are you going to do anything with the files other than reading them into memory?
There is the special syntax in imread for TIFF files of
Parameter name Value
-------------- -----
....
'PixelRegion' {ROWS, COLS}. imread returns the sub-image
specified by the boundaries in ROWS and COLS. ROWS
and COLS must be either two- or three-element
vectors. If two elements are provided, they denote
the 1-based indices [START STOP]. If three elements
are provided, the indices [START INCREMENT STOP]
allow image downsampling.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!