Exemplo n.º 1
0
    def _image_parameters(self, index):
        """
        Get the image parameters for the sidd at `index`.

        Parameters
        ----------
        index

        Returns
        -------
        (int, int, str, numpy.dtype, Union[bool, callable], str, tuple, tuple)
            pixel_size - the size of each pixel in bytes.
            abpp - the actual bits per pixel.
            irep - the image representation
            dtype - the data type.
            complex_type -
            pv_type - the pixel type string.
            band_count - the number of bands
            irepband - the image representation.
            im_segments - Segmentation of the form `((row start, row end, column start, column end))`
        """

        sidd = self.sidd_meta[index]
        assert isinstance(sidd, (SIDDType, SIDDType1))
        if sidd.Display.PixelType == 'MONO8I':
            pixel_size = 1
            abpp = 8
            irep = 'MONO'
            dtype = numpy.dtype('>u1')
            complex_type = False
            pv_type = 'INT'
            band_count = 1
            irepband = ('M', )
        elif sidd.Display.PixelType == 'MONO16I':
            pixel_size = 2
            abpp = 16
            irep = 'MONO'
            dtype = numpy.dtype('>u1')
            complex_type = False
            pv_type = 'INT'
            band_count = 1
            irepband = ('M', )
        elif sidd.Display.PixelType == 'RGB24I':
            pixel_size = 3
            abpp = 8
            irep = 'RGB'
            dtype = numpy.dtype('>u1')
            complex_type = False
            pv_type = 'INT'
            band_count = 3
            irepband = ('R', 'G', 'B')
        else:
            raise ValueError('Unsupported PixelType {}'.format(
                sidd.Display.PixelType))

        image_segment_limits = image_segmentation(
            sidd.Measurement.PixelFootprint.Row,
            sidd.Measurement.PixelFootprint.Col, pixel_size)
        return pixel_size, abpp, irep, dtype, complex_type, pv_type, band_count, irepband, image_segment_limits
Exemplo n.º 2
0
    def _image_parameters(self):
        """
        Get the image parameters.

        Returns
        -------
        (int, numpy.dtype, Union[bool, callable], str, tuple, tuple)
            pixel_size - the size of each pixel in bytes.
            dtype - the data type.
            transform_data - the transform_data parameters
            pv_type - the pixel type string.
            isubcat - the image subcategory.
            im_segments - Segmentation of the form `((row start, row end, column start, column end))`
        """

        pixel_type = self.sicd_meta.ImageData.PixelType  # required to be defined
        # NB: SICDs are required to be stored as big-endian, so the endian-ness
        #   of the memmap must be explicit
        if pixel_type == 'RE32F_IM32F':
            pv_type, isubcat = 'R', ('I', 'Q')
            pixel_size = 8
            dtype = numpy.dtype('>f4')
            transform_data = 'COMPLEX'
        elif pixel_type == 'RE16I_IM16I':
            pv_type, isubcat = 'SI', ('I', 'Q')
            pixel_size = 4
            dtype = numpy.dtype('>i2')
            transform_data = complex_to_int
        elif pixel_type == 'AMP8I_PHS8I':
            pv_type, isubcat = 'INT', ('M', 'P')
            pixel_size = 2
            dtype = numpy.dtype('>u1')
            transform_data = complex_to_amp_phase(
                self.sicd_meta.ImageData.AmpTable)
        else:
            raise ValueError('Got unhandled pixel_type {}'.format(pixel_type))
        image_segment_limits = image_segmentation(
            self.sicd_meta.ImageData.NumRows, self.sicd_meta.ImageData.NumCols,
            pixel_size)
        return pixel_size, dtype, transform_data, pv_type, isubcat, image_segment_limits