easyidp.geotiff.tifffile_crop#

easyidp.geotiff.tifffile_crop(page, top, left, h, w)#

Extract a crop from a TIFF image file directory (IFD) by partial loading.

Only the tiles englobing the crop area are loaded and not the whole page.

This is usefull for large geotiff that unableto load into RAM.

(0,0)
o--------------------------
|           ^
|           | top
|           v
| <-------> o=============o  ^
|   left    |<---- w ---->|  |
|           |             |  h
|           |             |  |
|           o=============o  v
Parameters:
  • page (TiffPage) – TIFF image file directory (IFD) from which the crop must be extracted.

  • top (int) – Coordinates of the top left corner of the desired crop. top = i0 = height_st left = j0 = w_st

  • left (int) – Coordinates of the top left corner of the desired crop. top = i0 = height_st left = j0 = w_st

  • h (int) – Desired crop height.

  • w (int) – Desired crop width.

Returns:

out – Extracted crop.

Return type:

ndarray of shape (h, w, sampleperpixel)

Notes

Modified from [1] ,

In EasyIDP v1.0, the function is caas_lite.get_crop(page, i0, j0, h, w)

Example

with tf.TiffFile(maize_part_dom) as tif:
    page = tif.pages[0]

    cropped = idp.geotiff.tifffile_crop(page, top=30, left=40, h=100, w=150)

Caution

It is not recommended to use without specifying parameters like this:

crop_rectiange(434, 918, 320, 321)

It is hard to know the parameter order immediately.