MATLAB Answers

how can i load into MATLAB specific pixels of a .tiff file?

20 views (last 30 days)
I need to load into MATLAB a lot of .tiff files (a few thousands), and to speed the process I wanted to read only the interesting pixels (or index) from any file.
is there a way to do it without loading the full files?


Sign in to comment.

Accepted Answer

Pratheek Punchathody
Pratheek Punchathody on 22 Jan 2021
Refer to the documentation on Read Specified Region of TIFF Image which alows you to read the specified region of the TIFF image. If that does not suit your needs then possibly reading in portions of it and cropping as you go can be a better option.


Show 1 older comment
Itamar Engelman
Itamar Engelman on 24 Jan 2021
can i save this tiff format using MATLAB?
whenever i save tiff (single precision) using this format: , it wont save it with sparse, so at the end it takes longer time to load the data into the matlab WS.
we have simulation that uses this images (we can save them in any format we desired) and we like to accelerate the simulink simulation (which 90% of the consumed time is the loading images)
for the time being, MAT files in -v7.3 loading partial image (by idx) give the best resaults, and we are looking for a way to accelerate it even more.(unfortanetly we need to use single at the time being)
any idea?
Walter Roberson
Walter Roberson on 24 Jan 2021 is an interface to gdal which supports sparse tiff files, and can do so automatically (tiles with content 0 are not written if the flag is set)
imwrite() would not be suitable for writing selected tiles, but the Tiff() matlab class can do so. Your reading code would need to check which tiles existed. I think gdal's developed interface would be easier to deal with.
Walter Roberson
Walter Roberson on 24 Jan 2021
It even might happen to be the case that the new georaster function can read such a file; that would have to be tested
Note that the geotiff and gdal functions return full arrays and that Simulink has no sparse signal support. What you would gain would be in reduced file operations but full memory arrays would have to be used. But you could lose a lot of efficiency back if you were doing the tiff tile handling at the MATLAB level to reconstruct the entire matrix, which is one of the reasons I would suggest farming out to gdal for its built-in handling.

Sign in to comment.

More Answers (0)



Community Treasure Hunt

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

Start Hunting!