def __init__(self, ifd, sample_index=0):
        self.ifd = ifd
        self.sample_index = sample_index

        self.planar_config = planar_config = ifd.get_value('PlanarConfiguration')

        self.samples_per_pixel = samples_per_pixel = ifd.get_value('SamplesPerPixel')

        if sample_index is not None and sample_index >= samples_per_pixel:
            raise IndexError ('sample index %r must be less that nof samples %r' % (sample_index, samples_per_pixel))

        pixels_per_row = ifd.get_value('ImageWidth')
        rows_of_pixels = ifd.get_value('ImageLength')
        self.shape = (int(rows_of_pixels), int(pixels_per_row))

        rows_per_strip = ifd.get_value('RowsPerStrip')
        strips_per_image = (rows_of_pixels + rows_per_strip - 1) // rows_per_strip
        rows_per_strip = min(rows_of_pixels, rows_per_strip)
        self.rows_per_strip = rows_per_strip

        self.strip_offsets = strip_offsets = ifd.get_value('StripOffsets')
        self.strip_nbytes = strip_nbytes = ifd.get_value('StripByteCounts')
        self.sample_format = sample_format = ifd.get_value('SampleFormat')
        self.bits_per_sample = bits_per_sample = ifd.get_value('BitsPerSample')

        bits_per_pixel = sum(bits_per_sample)
        assert bits_per_pixel % 8==0, `bits_per_pixel, bits_per_sample`
        bytes_per_pixel = bits_per_pixel // 8
        
        if sample_index is None:
            bytes_per_sample = bytes_per_pixel
        else:
            bytes_per_sample = bits_per_sample[sample_index] // 8
        bytes_per_row = bytes_per_pixel * pixels_per_row
        bytes_per_strip = rows_per_strip * bytes_per_row

        sample_names = ifd.get_sample_names()
        pixel_dtype = ifd.get_pixel_dtype()

        sample_offset = 0
        if sample_index is None:
            dtype = pixel_dtype
            sample_names = ['pixel']
            sample_name = 'pixel'
        else:
            dtype = ifd.get_sample_dtypes ()[sample_index]
            sample_name = sample_names[sample_index]
            if planar_config==1:
                sample_offset = sum(bits_per_sample[:sample_index]) // 8

        bytes_per_row = pixels_per_row * bytes_per_pixel # uncompressed

        sample_offset = 0
        if planar_config==1 or sample_index is None:
            bytes_per_sample_row = bytes_per_row
        else:
            bytes_per_sample_row = bytes_per_row // samples_per_pixel

        self.dtype = dtype
        self.pixel_dtype = pixel_dtype

        self.bytes_per_pixel = bytes_per_pixel
        self.bytes_per_row = bytes_per_row
        self.bytes_per_sample_image = bytes_per_sample_row * rows_of_pixels
        self.uncompressed_bytes_per_strip = bytes_per_strip
        self.compression = compression = ifd.get_value('Compression')
        self.sample_name = sample_name
        self.sample_offset = sample_offset
        self.bytes_per_sample_row = bytes_per_sample_row
        self.strips_per_image = strips_per_image
        self.is_contiguous = compression==1 and ifd.is_contiguous()

        time = None
        descr = ifd.get_value('ImageDescription', human=True)
        if descr is not None:
            if descr.startswith ('<?xml') or descr[:4].lower()=='<ome':
                pass
            else:
                it = descr.find('RelativeTime')
                if it != -1:
                    time = float(descr[it:].split (None, 2)[1].strip())
        self.time = time
Construct TiffSamplePlane instance.
dataset/ETHPy150Open pearu/pylibtiff/libtiff/tiff_sample_plane.py/TiffSamplePlane.__init__