o
    iO                 	   @   s
  U d Z ddlmZmZmZ ddlZddlmZ ddlm	Z	m
Z
 ddlZddlmZmZmZmZ zddlZdZW n eyB   dZY nw dd	lmZ dd
lmZmZ ddlmZ ddlmZmZmZm Z m!Z" ddl#m$Z$ ddl%m&Z&m'Z' ddl(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z< erddl=m>Z> e?e@ZAeeBdgeBeCB f ZDeddeEeFeFeGB f gdf ZHG dd deddZIdddddeEeFeFeGB f ddfddZJ	d2dddddeKddfddZLd3dd ZMeJgZNeOeH ePd!< G d"d deZQG d#d$ d$e ZReRe)ZSeRe*ZTeRe+ZUeRe,ZVeRe-ZWeWXg d% eRe.ZYeYXg d% eRe/ZZeZXd&d'g eRe0Z[e[Xd&d'g eRe1Z\e\Xg d( eRe2Z]e]Xg d( eRe3Z^e^Xg d% eRe4Z_e_Xg d% eRe5Z`e`ad)d* eRe6Zbebad)d* eRe7Zcecad)d* eRe8ZdedXd'd+g i e)eSd,fe*eTd,fe,eVd,fe+eUd,fe-eWd,fe.eYd,fe/eZd,fe0e[d,fe1e\d,fe2e]d,fe3e^d,fe4e_d,fe5e`d,fe6ebd,fe7ecd,fe8edd,fZed4d-d.Zfef  d/eFdeRfd0d1ZgdS )5zPixel data decoding.    )CallableIteratorIterableN)BufferedIOBase)ceilfloor)AnyBinaryIOcastTYPE_CHECKINGTF)config)	get_framegenerate_frames)warn_and_log)Buffer
RunnerBaseRunnerOptions	CoderBasePhotometricInterpretation)convert_color_space)_get_jpg_parametersget_j2k_parameters)ImplicitVRLittleEndianExplicitVRLittleEndianExplicitVRBigEndianDeflatedExplicitVRLittleEndianJPEGBaseline8BitJPEGExtended12BitJPEGLosslessJPEGLosslessSV1JPEGLSLosslessJPEGLSNearLosslessJPEG2000LosslessJPEG2000HTJ2KLosslessHTJ2KLosslessRPCLHTJ2KRLELosslessUIDJPEG2000TransferSyntaxesJPEGLSTransferSyntaxesJPEGTransferSyntaxesDatasetDecodeRunner
np.ndarrayc                   @   sr   e Zd ZU dZeed< eed< eed< eed< eed< eed< eed< eed	< eed
< eed< eed< eed< dS )DecodeOptionsz5Options accepted by DecodeRunner and decoding pluginspixel_vrallow_excess_framescorrect_unused_bits	view_only
be_swap_owrle_segment_order	byteorderapply_jls_sign_correctionapply_j2k_sign_correctionas_rgb	force_rgb	force_ybrN)__name__
__module____qualname____doc__str__annotations__bool rD   rD   R/mnt/sdb/aimis/docanh/lib/python3.10/site-packages/pydicom/pixels/decoders/base.pyr0   E   s   
 r0   )totalarrrunnerchangesreturnc                 C   s   | dd}| dd}|r|rtd|jtjtjfv o"| ddp$|}| jjs<|s-|r<| ddr8t	d | 
 } |rMt| tjtj} tj|d< | S |r\t| tjtj} tj|d< | S )	z4Convert `arr` to a given color space, typically RGB.r<   Fr;   z/'force_ybr' and 'force_rgb' cannot both be Truer:   r4   zeUnable to return an ndarray that's a view on the original buffer if applying a color space conversionphotometric_interpretation)
get_option
ValueErrorrK   PIYBR_FULLYBR_FULL_422flags	writeableLOGGERwarningcopyr   RGB)rG   rH   rI   r<   r;   to_rgbrD   rD   rE   _process_color_spacek   s.   


rX   log_warningc                 C   sj   |r| ddr|jjs| jjstd | jjs|  } |j|j	 }t
j| || d t
j| || d | S )zFPerform a bit-shift correction on `arr` to avoid using any unused bitsr4   Fa4  Unable to return an ndarray that's a view on the original buffer when (0028,0101) 'Bits Stored' doesn't equal (0028,0100) 'Bits Allocated' and 'correct_unused_bits=True'. In most cases you can pass 'correct_unused_bits=False' instead to get a view if the uncorrected array is equivalent to the corrected one.out)rL   transfer_syntaxis_encapsulatedrQ   rR   rS   rT   rU   bits_allocatedbits_storednp
left_shiftright_shift)rG   rH   rY   	bit_shiftrD   rD   rE   _correct_unused_bits   s"   
rd   c                 C   s   |j tv r4|d|j}|d|j}d| jj | }|r2||jkr2tj| || d tj	| || d | S |j t
v rZ|d|j}d| jj | }|rZtj| || d tj	| || d | S )zMConvert `arr` to match the signedness required by the 'pixel_representation'.j2k_is_signedj2k_precision   rZ   jls_precision)r\   r)   rL   pixel_representationr_   dtypeitemsizer`   ra   rb   r*   )rG   rH   
j2k_signed	precisionrc   rD   rD   rE   _apply_sign_correction   s   


rn   
PROCESSORSc                	       s  e Zd ZdZdeddfddZdeeef ddfdd	Z	d
e
deeB fddZdedeeB fddZdeeB de
de
defddZdeddfddZdeeeB  fddZed<ddZd=dedeeee
B f fddZdd ded eeee
B f f fd!d"Zd=dd dedd fd#d$Zd%eeef ddfd&d'Zd> fd*d+Zd?d-d.ZedeeB fd/d0Z defd1d2Z!d3edefd4d5Z"d@d6d7Z#d@d8d9Z$d@ fd:d;Z%  Z&S )Ar.   a   Class for managing the pixel data decoding process.

    .. versionadded:: 3.0

    This class is not intended to be used directly. For decoding pixel data
    use the :class:`~pydicom.pixels.decoders.base.Decoder` instance
    corresponding to the transfer syntax of the pixel data.
    tsyntaxrJ   Nc                 C   s   |  |  |ddd| _ d| _i | _|  | jjr| dd n| dd | jtv r1| dd dS | jtv r>| d	d dS | d
d dS )zCreate a new runner for decoding data encoded as `tsyntax`.

        Parameters
        ----------
        tsyntax : pydicom.uid.UID
            The transfer syntax UID corresponding to the pixel data to be
            decoded.
        T)transfer_syntax_uidr:   r2   )rq   pixel_keywordrr   	PixelDatar4   Fr9   r8   r3   N)_opts_undeletable	_decodersr\   r]   
set_optionr)   r*   )selfrp   rD   rD   rE   __init__   s"   	

zDecodeRunner.__init__infoc                 C   s   | j dkrdS | j}|ddg dg dfv }|r0|tjkr0| dtj td| d dS | jtkr8tj	ntj
}|d	i  D ]}|d
rbd|vrb| d| td| d| d  dS qCdS )zConform the photometric interpretation to the JPEG/JPEG-LS codestream.

        Parameters
        ----------
        info : dict[str, Any]
            A dictionary containing JPEG/JPEG-LS codestream metadata.
           Ncomponent_ids)R   G   B   )r   g   b   rK   z7The (0028,0004) 'Photometric Interpretation' value is 'z\' however the encoded image's codestream uses component IDs that indicate it should be 'RGB'apps   JFIFYBRzb' however the encoded image's codestream contains a JFIF APP marker which indicates it should be '')samples_per_pixelrK   getrN   rV   rw   r   r\   r   rP   rO   values
startswith)rx   rz   pihas_rgb_idscsmarkerrD   rD   rE   _conform_jpg_colorspace  s2   

z$DecodeRunner._conform_jpg_colorspaceindexc                 C   s*   t | j|| j| jd}| | | |S )a  Decode the frame of pixel data at `index`.

        Parameters
        ----------
        index : int
            The index of the frame to be decoded.

        Returns
        -------
        bytes | bytearray
            The decoded frame of pixel data.
        number_of_framesextended_offsets)r   srcr   r   _get_frame_info_decode_frame)rx   r   r   rD   rD   rE   decode5  s   

zDecodeRunner.decoder   c                 C   s   g }| j  D ]Q\}}z,||| }t| dr.| jd |kr.td| jd  d| d| d ||f| _|W   S  tyX } zt| || d|  W Y d	}~qd	}~ww d
	|}t
d| )a  Return a decoded frame of pixel data.

        Parameters
        ----------
        src : bytes
            An encoded frame of pixel data to be passed to the decoding plugins.

        Returns
        -------
        bytes | bytearray
            The decoded frame.
        	_previous   z&The decoding plugin has changed from 'r   z' to 'zq' during the decoding process - you may get inconsistent inter-frame results, consider passing 'decoding_plugin="z
"' instead: Nz
  zGUnable to decode as exceptions were raised by all available plugins:
  )rv   itemshasattrr   r   	ExceptionrS   	exceptionappendjoinRuntimeError)rx   r   failure_messagesnamefuncframeexcmessagesrD   rD   rE   r   N  s2   



 
zDecodeRunner._decode_frameoffsetlengthc                 C   sZ   | j s| jrtt|}||||  S tt|}| }|| ||}|| |S )af  Return `length` bytes from `src`, starting at `offset`.

        Parameters
        ----------
        src : buffer-like | file-like
            The source of the data to be returned. If a file-like then the file
            position after reading will returned to the original offset.
        offset : int
            The starting offset of the data in `src`.
        length : int
            The number of bytes to try to return.

        Returns
        -------
        bytes
            The data from `src`, may return fewer bytes if the end of `src` is
            reached before ``offset + length``.
        )
is_dataset	is_bufferr
   r   r	   tellseekread)rx   r   r   r   file_offsetbufferrD   rD   rE   get_data{  s   




zDecodeRunner.get_datac                 C   s   | j tv r!t|}| d|d| j | d|d| j dS | j tv r<t|}| d|d| j | 	| dS | j t
v rLt|}| 	| dS dS )z7Parse a frame's codestream for JPEG-related parameters.re   	is_signedrf   rm   rh   N)r\   r)   r   rw   r   ri   r_   r*   r   r   r+   )rx   r   j2k_infojls_infojpg_inforD   rD   rE   r     s$   


zDecodeRunner._get_frame_infoc              
   c   s    | j rtt| j }t| j| j| jd}t|D ]6\}}| 	| t
| dd\}}|rJz||| V  W q tyI   td| d|  Y nw | |V  q| j r_tt| j| dS dS )z1Yield decoded frames from the encoded pixel data.r   r   )NNzThe decoding plugin 'z&' failed to decode the frame at index N)	is_binaryr
   r	   r   r   r   r   r   	enumerater   getattrr   rS   rT   r   r   )rx   r   encoded_framesr   r   r   r   rD   rD   rE   iter_decode  s4   
zDecodeRunner.iter_decodenp.dtypec                 C   s   t std| j}|dkrtd}nB|dkrtd}n8d| j }| jdkr*d}n| jd	kr>| jd
 d	kr>|| jd
  7 }zt|}W n tyT   td| dw | j	j
tjdkkrc|d}|S )z^Return a :class:`numpy.dtype` suitable for containing the decoded
        pixel data.
        z0NumPy is required for 'DecodeRunner.pixel_dtype'FloatPixelDatafloat32DoubleFloatPixelDatafloat64uir   u1r   rg   zThe data type 'z<' needed to contain the pixel data is not supported by NumPylittleS)HAVE_NPImportErrorrr   r`   rj   ri   r^   	TypeErrorNotImplementedErrorr\   is_little_endiansysr7   newbyteorder)rx   rr   rj   	dtype_strrD   rD   rE   pixel_dtype  s,   



zDecodeRunner.pixel_dtypeFas_framec                 C   sr   | j | j|s	| jndt| j| j| jd}| jdkr| j|d< | jdkr.| j	|d< | j
|d< tttttB f |S )a  Return a dict containing the :dcm:`Image Pixel
        <part03/sect_C.7.6.3.html>` module related properties.

        Parameters
        ----------
        as_frame : bool, optional
            If ``True`` then don't include properties that aren't appropriate
            for a single frame. Default ``False``.

        Returns
        -------
        dict[str, str | int]
            A dict containing the values for:

            * `bits_allocated`
            * `bits_stored`
            * `columns`
            * `photometric_interpretation`
            * `samples_per_pixel`
            * `rows`
            * `number_of_frames`
            * `planar_configuration` (if `samples_per_pixel` > 1)
            * `pixel_representation` (if the pixel keyword is ``"PixelData"``)

            The returned values depend on whether or not this method is
            called before or after decoding the pixel data, as the decoding
            plugins and image processing functions may update the values as
            needed to reflect the corresponding decoded data. For example, if
            the pixel data is converted from the YCbCr to RGB color space then
            the `photometric_interpretation` value will be changed to match
            after the data has been decoded.
        r   )r^   columnsr   rK   rowsr   planar_configurationrs   r_   ri   )r^   r   r   rA   rK   r   r   r   rr   r_   ri   r
   dictint)rx   r   drD   rD   rE   pixel_properties  s   "
	



zDecodeRunner.pixel_propertiesrG   r/   c                 C   s"   i }t D ]}||| |}q||fS )aL  Return `arr` after applying zero or more processing operations.

        Returns
        -------
        numpy.ndarray
            The array with the applied processing.
        dict[str, int | str]
            A :class:`dict` containing any required changes to the image pixel
            properties due to the processing.
        )ro   )rx   rG   rI   r   rD   rD   rE   process-  s   zDecodeRunner.processc                 C   s   | j }| j}| j}| j}|s:|dkr:|dkr||||S | jdkr*|||||S |||||}|ddddS |dkrD|||S | jdkrP||||S ||||}|dddS )a  Return a reshaped :class:`~numpy.ndarray` `arr`.

        Parameters
        ----------
        arr : np.ndarray
            The 1D array to be reshaped.
        as_frame : bool, optional
            If ``True`` then treat `arr` as only containing a single frame's
            worth of pixel data, otherwise treat `arr` as containing the full
            amount of pixel data (default).

        Returns
        -------
        np.ndarray
            A view of the input `arr` reshaped to:

            * (rows, columns) for single frame, single sample data
            * (rows, columns, samples) for single frame, multi-sample data
            * (frames, rows, columns) for multi-frame, single sample data
            * (frames, rows, columns, samples) for multi-frame, multi-sample data
        r   r      r{   )r   r   r   r   reshaper   	transpose)rx   rG   r   r   r   r   r   rD   rD   rE   r   >  s"   

zDecodeRunner.reshapedecodersc                 C   s   || _ t| dr| `dS dS )zSet the decoders use for decoding compressed pixel data.

        Parameters
        ----------
        decoders : dict[str, DecodeFunction]
            A dict of {name: decoder function}.
        r   N)rv   r   r   )rx   r   rD   rD   rE   set_decodersr  s   
zDecodeRunner.set_decodersdsr-   c                    s   t    t di }|dd }r"|| jkr"td|j dg d} fdd|D }|s5td	t|d
kr?td| 	d|d  | 	d |d  j
 dS )zSet options using a dataset.

        Parameters
        ----------
        ds : pydicom.dataset.Dataset
            The dataset to use.
        	file_metaTransferSyntaxUIDNzThe dataset's transfer syntax 'z&' doesn't match the pixel data decoder)rs   r   r   c                    s   g | ]}| v r|qS rD   rD   ).0kwr   rD   rE   
<listcomp>  s    z0DecodeRunner._set_options_ds.<locals>.<listcomp>zqThe dataset has no 'Pixel Data', 'Float Pixel Data' or 'Double Float Pixel Data' element, no pixel data to decoder   zoOne and only one of 'Pixel Data', 'Float Pixel Data' or 'Double Float Pixel Data' may be present in the datasetrr   r   r1   )super_set_options_dsr   r   r\   rM   r   AttributeErrorlenrw   VR)rx   r   r   rp   keywords
px_keyword	__class__r   rE   r   ~  s&   
zDecodeRunner._set_options_dsBuffer | Dataset | BinaryIOc                 C   sx   ddl m} t||r'| | || j j| _t| jtr"d| _dS d| _dS t	|dr4|| _d| _dS || _d| _dS )a^  Set the pixel data to be decoded.

        Parameters
        ----------
        src : bytes | bytearray | memoryview | pydicom.dataset.Dataset
            If a buffer-like then the encoded pixel data, otherwise the
            :class:`~pydicom.dataset.Dataset` containing the pixel data and
            associated group ``0x0028`` elements.
        r   r,   r	   r-   r   r   N)
pydicom.datasetr-   
isinstancer   rr   value_srcr   	_src_typer   )rx   r   r-   rD   rD   rE   
set_source  s   







zDecodeRunner.set_sourcec                 C   s   | j S )zFReturn the buffer-like or file-like containing the encoded pixel data.)r   rx   rD   rD   rE   r     s   zDecodeRunner.srcc                 C   sf   d| j j dg}|d |dd | j D  | jr.|d |dd | jD  d|S )	z)Return nice string output for the runner.zDecodeRunner for 'r   Optionsc                 S   s    g | ]\}}d | d| qS )  r   rD   )r   r   r   rD   rD   rE   r     s     z(DecodeRunner.__str__.<locals>.<listcomp>Decodersc                 S   s   g | ]}d | qS )r   rD   )r   r   rD   rD   rE   r     s    
)r\   r   r   extendoptionsr   rv   r   )rx   srD   rD   rE   __str__  s   


zDecodeRunner.__str__testc                 C   s   |dkr#|  drdS | jj o"| jd dko"| jdko"|  ddkS |dkrO| jtv o:| jtjtj	fv o:|  d	d
}| jt
v oJ| jdkoJ|  dd
}|pN|S |dkrd|  dd
oc| jdkoc| j| jkS td| d)z-Return the result of `test` as :class:`bool`.r5   Trg   r   rs   r1   OWsign_correctionr9   Fr8   shift_correctionr3   zUnknown test 'r   )rL   r\   r   r^   rr   r)   rK   rN   MONOCHROME1MONOCHROME2r*   ri   r_   rM   )rx   r   use_j2k_correctionuse_jls_correctionrD   rD   rE   	_test_for  s:   






zDecodeRunner._test_forc                 C   s$   |    | js
| jr|   dS dS )z9Validate the decoding options and source buffer (if any).N)_validate_optionsr   r   _validate_bufferr   rD   rD   rE   validate  s   zDecodeRunner.validatec                 C   s@  | j dd}t|| j }ttt| j}| jjr)||||d  fv r't	d dS ||d  }||k rD||krBt
d| d| ddS ||kr| jtjkrh|d d	 }|||d  krgt
d
| d| dn'| ddr|| }|| jkrt	d| d| j d| j d | d| dS t	d| d||  d dS dS )z"Validate the supplied buffer data.bytesunitr   zThe number of bytes of compressed pixel data matches the expected number for uncompressed data - check that the transfer syntax has been set correctlyNz9The number of bytes of pixel data is less than expected (z vs zy bytes) - the dataset may be corrupted, have an invalid group 0028 element value, or the transfer syntax may be incorrectr{   zCThe number of bytes of pixel data is a third larger than expected (z bytes) which indicates the set (0028,0004) 'Photometric Interpretation' value of 'YBR_FULL_422' is incorrect and may need to be changed to either 'RGB' or 'YBR_FULL'r2   Fz;The number of bytes of pixel data is sufficient to contain zO frames which is larger than the given (0028,0008) 'Number of Frames' value of . The returned data will include these extra frames and if it's correct then you should update 'Number of Frames' accordingly, otherwise pass 'allow_excess_frames=False' to return only the first  frames.r   zThe pixel data is z) bytes long, which indicates it contains z& bytes of excess padding to be removed)frame_lengthr   r   r   r
   r   r   r\   r]   r   rM   rK   rN   rP   rL   rw   )rx   r  expectedactualpadded
ybr_lengthwhole_framesrD   rD   rE   r    sh   

	zDecodeRunner._validate_bufferc                    sJ   t    | jr!t| jd t| jd kr#td | d dS dS dS )zGValidate the supplied options to ensure they meet minimum requirements.r   r   zThe number of items in (7FE0,0001) 'Extended Offset Table' and (7FE0,0002) 'Extended Offset Table Lengths' don't match - the extended offset table will be ignoredr   N)r   r  r   r   r   
del_optionr   r   rD   rE   r  4  s   
zDecodeRunner._validate_options)rJ   r   )F)r   r-   rJ   N)r   r   rJ   NrJ   N)'r=   r>   r?   r@   r(   ry   r   rA   r   r   r   r  	bytearrayr   r   r   r	   r   r   r   r   propertyr   rC   r   tupler   r   DecodeFunctionr   r   r   r   r   r  r  r  r  __classcell__rD   rD   r   rE   r.      s0    	 '-" *&34
#
$
?c                       s  e Zd ZdZdeddf fddZdddd	d
dddedB dededede	de
deeeeB f f fddZedededB ddfddZedededB ddfddZddd	ddddedB dededede
eeeeeB f f fddZedededB deeB fddZedededB defdd Zdddd	d!ddd"ee dB dededededee
deeeeB f f  fd#d$Zddd	d%ddd"ee dB dedededee
eeeeeB f f  fd&d'Z  ZS )(DecoderaP  Factory class for pixel data decoders.

    Every available ``Decoder`` instance in *pydicom* corresponds directly
    to a single DICOM *Transfer Syntax UID*, and provides a  mechanism for
    decoding encoded source data using one or more :doc:`decoding plugins
    </guides/decoding/decoder_plugins>`.

    .. versionadded:: 3.0
    uidrJ   Nc                    s   t  j|dd dS )zCreate a new data decoder.

        Parameters
        ----------
        uid : pydicom.uid.UID
            The *Transfer Syntax UID* that the decoder supports.
        T)decoderN)r   ry   )rx   r  r   rD   rE   ry   O  s   zDecoder.__init__TF )r   r  rawdecoding_pluginr   zDataset | Buffer | BinaryIOr   r  r  r  kwargsr/   c                K   sL  t std|dur|dk rtdt| j}|| |jdi | |tt	t
df | | tjr;t| |rA|  | jrO| j}|dd }	n| j}d}	|du}
|j||||
d	}|d
rmt||}n
|drwt||}i }|s||\}}|jjs|	r| n|}|jdkrd|d< |j|
d	}|| ||fS )a  Return decoded pixel data as :class:`~numpy.ndarray`.

        .. warning::

            This method requires `NumPy <https://numpy.org/>`_ and may require
            the installation of additional packages to perform the actual pixel
            data decoding. See the :doc:`pixel data decompression documentation
            </guides/user/image_data_handlers>` for more information.

        **Processing**

        The following processing operations on the raw pixel data are always
        performed:

        * Natively encoded bit-packed pixel data for a :ref:`bits allocated
          <bits_allocated>` of ``1`` will be unpacked.
        * Natively encoded pixel data with a :ref:`photometric interpretation
          <photometric_interpretation>` of ``"YBR_FULL_422"`` will
          have it's sub-sampling removed.
        * The output array will be reshaped to the specified dimensions.
        * JPEG-LS or JPEG 2000 encoded data whose signedness doesn't match the
          expected :ref:`pixel representation<pixel_representation>` will be
          converted to match.

        If ``raw = False`` (the default) then the following processing operation
        will also be performed:

        * Pixel data with a :ref:`photometric interpretation
          <photometric_interpretation>` of ``"YBR_FULL"`` or
          ``"YBR_FULL_422"`` will be converted to RGB.

        Parameters
        ----------
        src : :class:`~pydicom.dataset.Dataset` | buffer-like | file-like
            Single or multi-frame pixel data as one of the following:

            * :class:`~pydicom.dataset.Dataset`: a dataset containing
              the pixel data to be decoded and the corresponding
              *Image Pixel* module elements.
            * :class:`bytes` | :class:`bytearray` | :class:`memoryview`: the
              encoded (and possibly encapsulated) pixel data to be decoded.
            * :class:`~typing.BinaryIO`: a file-like positioned at the start of
              the pixel data element's value. The position will be returned
              to the starting offset prior to returning the array.

            When `src` is not a :class:`~pydicom.dataset.Dataset` then a number
            of keyword parameters are also required. Please see the
            :doc:`decoding options documentation</guides/decoding/decoder_options>`
            for more information.
        index : int | None, optional
            If ``None`` (default) then return an array containing all the
            frames in the pixel data, otherwise return one containing only
            the frame from the specified `index`, which starts at 0 for the
            first frame.
        raw : bool, optional
            If ``True`` then return the decoded pixel data after only
            minimal processing (see the processing section above). If ``False``
            (default) then additional processing may be applied to convert the
            pixel data to it's most commonly used form (such as converting from
            YCbCr to RGB). To return the raw pixel data with no processing
            whatsoever, use the :meth:`~pydicom.pixels.decoders.base.Decoder.as_buffer`
            method.
        validate : bool, optional
            If ``True`` (default) then validate the supplied decoding options
            and encoded pixel data prior to decoding, otherwise if ``False``
            no validation will be performed.
        decoding_plugin : str, optional
            The name of the decoding plugin to use when decoding compressed
            pixel data. If no `decoding_plugin` is specified (default) then all
            available plugins will be tried and the result from the first successful
            one returned. For information on the available plugins for each
            decoder see the :doc:`API documentation</reference/pixels.decoders>`.
        **kwargs
            Optional keyword parameters for controlling decoding are also
            available, please see the :doc:`decoding options documentation
            </guides/decoding/decoder_options>` for more information.

        Returns
        -------
        numpy.ndarray
            One or more frames of decoded pixel data shaped as:

            * (rows, columns) for single frame, single sample data
            * (rows, columns, samples) for single frame, multi-sample data
            * (frames, rows, columns) for multi-frame, single sample data
            * (frames, rows, columns, samples) for multi-frame, multi-sample data

            The :class:`~numpy.dtype` for the array will have an
            :attr:`~numpy.dtype.itemsize` sufficient to contain pixels of at
            least :ref:`bits allocated<bits_allocated>`.

            A writeable :class:`~numpy.ndarray` is returned by default. For
            native transfer syntaxes with ``view_only=True``, a read-only
            :class:`~numpy.ndarray` will be returned if `src` is immutable.
        dict[str, str | int]
            The :dcm:`Image Pixel<part03/sect_C.7.6.3.html>` module element
            values resulting from the decoding process that describe the array.
            See :meth:`DecodeRunner.pixel_properties()
            <pydicom.pixels.decoders.base.DecodeRunner.pixel_properties>` for the
            possible contents.
        :NumPy is required when converting pixel data to an ndarrayNr   z*'index' must be greater than or equal to 0r  r4   FTr   r   r   r   r   rD   ) r   r   rM   r.   r(   r   set_optionsr   r
   r   rA   _validate_pluginsr   	debuggingrS   debugr  	is_native_as_array_nativerL   _as_array_encapsulatedr   r  rn   rd   r   rQ   rR   rU   r   r   update)rx   r   r   r  r  r  r  rH   r   as_writeabler   rG   	overridesr   rD   rD   rE   as_arrayY  sN   o








zDecoder.as_arrayrH   c                 C   sZ  | j }tt| jdd}|durdn| j}tj|| | jd}|dur;tj| j	|d| jd|dd< | 
d| |S |  }t| jD ]}t|}|| }	tj|| jd||	|	| < qD| dd	rg }
| j}|D ]}t|| jd
dkr|
t|| j | 
d| jd  qj|
rtt|
|  d| d| d t|g|
}| 
d| |S )a  Return compressed and encapsulated pixel data as :class:`~numpy.ndarray`.

        Parameters
        ----------
        runner : pydicom.pixels.decoders.base.DecodeRunner
            The runner with the encoded data and decoding options.
        index : int | None
            The index of the frame to be returned, or ``None`` if all frames
            are to be returned

        Returns
        -------
        numpy.ndarray
            A 1D array containing the pixel data.
        pixelsr  Nr   rj   r   r^   r2   Fr  r    frames have been found in the encapsulated pixel data, which is larger than the given (0028,0008) 'Number of Frames' value of r	  r
  )r^   r
   r   r  r   r`   emptyr   
frombufferr   rw   r   rangenextrL   r   r   r   concatenate)rH   r   original_bits_allocatedpixels_per_framer   rG   frame_generatoridxr   startexcessoriginal_nr_framesrD   rD   rE   r'     sD    	zDecoder._as_array_encapsulatedc                 C   s  | j dd}t| j dd}| j}| js| jr&ttt| j}d}t	|}ntt
| j}| }|| j }| dr| ddrEtd tt|}tt|}|d	ur|||  }|| || krktd
|d  d|d dkr| |||}	tj|	dd }
|
|}
n|d }| ||| |d }	tj|	dd }
|
|||rd	nd }
ng|| j9 }| ||||d  }tj|dd }
|
|d	| }
nD|d	urt|||  }|| || krtd
|d  d| ||t|}	tj|	|d}
n|| j9 }| ||t|}tj||d}
| jdkrO| ddr&td d}|d	u r3|| j9 }n|| d }tj|
dt|d d}||||  }|S | jtjkrX|
S | ddrdtd tj|
jd d d |d}|
d	d	d |d	d	d< |
dd	d |dd	d< |
dd	d |
dd	d |dd	d< |dd	d< |
dd	d |
dd	d |dd	d< |dd	d< |  dtj! |S )a  Return natively encoded pixel data from a buffer-like as
        :class:`~numpy.ndarray`.

        Parameters
        ----------
        runner : pydicom.pixels.decoders.base.DecodeRunner
            The runner with the encoded data and decoding options.
        index : int | None
            The index of the frame to be returned, or ``None`` if all frames
            are to be returned

        Returns
        -------
        numpy.ndarray
            A 1D array containing the pixel data.
        r  r  r,  r   r5   r4   FzUnable to return an ndarray that's a view on the original buffer for 8-bit pixel data encoded as OW with 'Explicit VR Big Endian'N,There is insufficient pixel data to contain r    framesr   u2r-  zZUnable to return an ndarray that's a view on the original buffer for bit-packed pixel datarg   r   )bitordercountzUnable to return an ndarray that's a view on the original buffer for uncompressed pixel data with a photometric interpretation of 'YBR_FULL_422'r{            rK   )"r  r   r   r   r   
memoryviewr
   r   r   r   r	   r   r   r  rL   rS   rT   rM   r   r`   r1  byteswapviewr   r   r^   
unpackbitsrK   rN   rP   r0  shaperw   rO   )rH   r   length_byteslength_pixelsrj   r   r   length_sourcestart_offsetr   rG   	odd_indexr   bit_offset_startunpackedr[   rD   rD   rE   r&  K  s   







22zDecoder._as_array_native)r   r  r  c                K   s   t | j}|| |jdi | |tttdf | | |r'|	  | j
r1| ||}n| ||}||j|dudfS )a[  Return the raw decoded pixel data as a buffer-like.

        .. warning::

            This method should only be used by advanced users who understand the
            intricacies of converting raw decoded DICOM pixel data to a usable
            form. It may also require the installation of additional packages
            to perform the actual pixel data decoding (see the :doc:`pixel data
            decompression documentation</guides/user/image_data_handlers>` for more
            information).

        Parameters
        ----------
        src : :class:`~pydicom.dataset.Dataset` | buffer-like | file-like
            Single or multi-frame pixel data as one of the following:

            * :class:`~pydicom.dataset.Dataset`: a dataset containing
              the pixel data to be decoded and the corresponding
              *Image Pixel* module elements.
            * :class:`bytes` | :class:`bytearray` | :class:`memoryview`: the
              encoded (and possibly encapsulated) pixel data to be decoded.
            * :class:`~typing.BinaryIO`: a file-like positioned at the start of the
              pixel data element's value. The position will be returned
              to the starting offset prior to returning the buffer.

            When `src` is not a :class:`~pydicom.dataset.Dataset` then a number
            of keyword parameters are also required. Please see the
            :doc:`decoding options documentation</guides/decoding/decoder_options>`
            for more information.
        index : int | None, optional
            If ``None`` (default) then return a buffer-like containing all the
            frames in the pixel data, otherwise return one containing only
            the frame from the specified `index`, which starts at 0 for the
            first frame.
        validate : bool, optional
            If ``True`` (default) then validate the supplied decoding options
            and encoded pixel data prior to decoding, otherwise if ``False``
            no validation will be performed.
        decoding_plugin : str, optional
            The name of the decoding plugin to use when decoding compressed
            pixel data. If no `decoding_plugin` is specified (default) then all
            available plugins will be tried and the result from the first successful
            one returned. For information on the available plugins for each
            decoder see the :doc:`API documentation</reference/pixels.decoders>`.
        **kwargs
            Optional keyword parameters for controlling decoding are also
            available, please see the :doc:`decoding options documentation
            </guides/decoding/decoder_options>` for more information.

        Returns
        -------
        bytes | bytearray | memoryview
            One or more frames of raw decoded pixel data.

            For natively encoded pixel data when `src` is a buffer-like the
            same type in `src` will be returned, except if `view_only` is
            ``True`` in which case a :class:`memoryview` on the original
            buffer will be returned instead. If `src` is a file-like then
            :class:`bytes` will always be returned.

            8-bit pixel data encoded as **OW** using *Explicit VR Big Endian* will
            be returned as-is and may need byte-swapping. To facilitate this
            an extra byte before the expected start (for an odd `index`) or after
            the expected end (for an even `index`) is returned if the frame contains
            an odd number of pixels.
        dict[str, str | int]
            The :dcm:`Image Pixel<part03/sect_C.7.6.3.html>` module element
            values resulting from the decoding process that describe the
            decoded pixel data. See :meth:`DecodeRunner.pixel_properties()
            <pydicom.pixels.decoders.base.DecodeRunner.pixel_properties>` for the
            possible contents.
        r  Nr   rD   )r.   r(   r   r!  r   r
   r   rA   r"  r  r%  _as_buffer_native_as_buffer_encapsulatedr   )rx   r   r   r  r  r  rH   r   rD   rD   rE   	as_buffer  s   
Q

zDecoder.as_bufferc              
   C   s&  |dur(| j |d}| jdd}t| }|kr&td| d| d| d|S g }g }|  }t| jD ]-}t|}|| j	 | jdd}t| }|kr]td| d| d| d|| q5| 
d	d
rg }	| j}
|D ] }t|| jddkr|	| | d| jd  || j	 qp|	rtt|	t|  d|
 d|
 d ||	 tt|dkr	t|}|d }tt||D ]?\}\}}||krtd| d| d| d |d }tt|| | }t|D ]}||d| ||d|< q|||< q| d| ddd |D S )a   "Return the raw decoded pixel data as a buffer-like.

        Parameters
        ----------
        runner : pydicom.pixels.decoders.base.DecodeRunner
            The runner with the encoded data and decoding options.
        index : int | None
            The index of the frame to be returned, or ``None`` if all frames
            are to be returned

        Returns
        -------
        bytes | bytearray
            A buffer-like containing the decoded pixel data.
        Nr.  r  r  z;Unexpected number of bytes in the decoded frame with index z (z bytes actual vs z
 expected)r2   Fr   r   r/  r	  r
  rg   zPadding frame z from z to z-bitr^       c                 s   s    | ]}|V  qd S )NrD   )r   brD   rD   rE   	<genexpr>  s    z2Decoder._as_buffer_encapsulated.<locals>.<genexpr>)r   r  r   rM   r   r2  r   r3  r   r^   rL   rw   r   r   setmaxr   ziprS   r$  r  r   )rH   r   r   rJ  r  framesr^   r7  r8  r:  r;  targettarget_stepactual_stepr[   r   rD   rD   rE   rR  G  s   

	
zDecoder._as_buffer_encapsulatedc                 C   s  | j dd}| js| jr(| ddrttt| j}ntt| j}d}t|}ntt	| j}|
 }|| j }| drtt|}tt|}|dur||||  }|| || krbtd|d	  d
|d dkro| |||S | |||d  |d	 S || j9 }| ||||d  S |durt|||  }|| || krtd|d	  d
| ||t|S || j9 }| ||t|S )a0   "Return the raw encoded pixel data as a buffer-like.

        Parameters
        ----------
        runner : pydicom.pixels.decoders.base.DecodeRunner
            The runner with the encoded data and decoding options.
        index : int | None
            The index of the frame to be returned, or ``None`` if all frames
            are to be returned

        Returns
        -------
        bytes | bytearray | memoryview
            A buffer-like containing the decoded pixel data. Will return the
            same type as in the buffer containing the pixel data unless
            `view_only` is ``True`` in which case a :class:`memoryview` of the
            original buffer will be returned instead.

        Notes
        -----
        For certain images, those with BitsAllocated=1, multiple frames and
        number of pixels per frame that is not a multiple of 8, it is not
        possible to isolate a buffer to a single frame because frame boundaries
        may occur within the middle a byte. If a single frame is requested (via
        ``index``) for these cases, the buffer returned will consist of the
        smallest set of bytes required to entirely contain the requested frame.
        However, the first and last byte may also contain information on pixel
        values in neighboring frames.
        r  r  r4   Fr   r5   Nr<  r   r=  r   )r  r   r   rL   rE  r
   r   r   r   r	   r   r   r  r   rM   r   r   r   )rH   r   rJ  r   r   rL  rM  rD   rD   rE   rQ    sB   






zDecoder._as_buffer_native)indicesr  r  r  r^  c                k   s$   t stdt| j}|| |jdi | |ttt	df | 
| tjr0t| |r6|  | jrD| j}|dd }	n| j}d}	d}
| jr|s| D ]X}tj||jd}|j|dd}|drpt||}n|d	r~t|||
d
}d}
i }|s||\}}|jjr|n|  }|j!dkrd|d< |j"dd}|#| ||fV  qTdS |r|nt$|j%}|D ]U}|j|||dd}|drt||}n|d	rt|||
d
}d}
i }|s||\}}|jjs|	r|  n|}|j!dkrd|d< |j"dd}|#| ||fV  qdS )a  Yield pixel data frames as :class:`~numpy.ndarray`.

        .. warning::

            This method requires `NumPy <https://numpy.org/>`_ and may require
            the installation of additional packages to perform the actual pixel
            data decoding. See the :doc:`pixel data decompression documentation
            </guides/user/image_data_handlers>` for more information.

        **Processing**

        The following processing operations on the raw pixel data are always
        performed:

        * Natively encoded bit-packed pixel data for a :ref:`bits allocated
          <bits_allocated>` of ``1`` will be unpacked.
        * Natively encoded pixel data with a :ref:`photometric interpretation
          <photometric_interpretation>` of ``"YBR_FULL_422"`` will
          have it's sub-sampling removed.
        * The output array will be reshaped to the specified dimensions.
        * JPEG-LS or JPEG 2000 encoded data whose signedness doesn't match the
          expected :ref:`pixel representation<pixel_representation>` will be
          converted to match.

        If ``raw = False`` (the default) then the following processing operation
        will also be performed:

        * Pixel data with a :ref:`photometric interpretation
          <photometric_interpretation>` of ``"YBR_FULL"`` or
          ``"YBR_FULL_422"`` will be converted to ``"RGB"``.

        Parameters
        ----------
        src : :class:`~pydicom.dataset.Dataset` | buffer-like | file-like
            Single or multi-frame pixel data as one of the following:

            * :class:`~pydicom.dataset.Dataset`: a dataset containing
              the pixel data to be decoded and the corresponding
              *Image Pixel* module elements.
            * :class:`bytes` | :class:`bytearray` | :class:`memoryview`: the
              encoded (and possibly encapsulated) pixel data to be decoded.
            * :class:`~typing.BinaryIO`: a file-like positioned at the start of the
              pixel data element's value. The position will be returned
              to the starting offset only after all frames have been yielded.

            When `src` is not a :class:`~pydicom.dataset.Dataset` then a number
            of keyword parameters are also required. Please see the
            :doc:`decoding options documentation</guides/decoding/decoder_options>`
            for more information.
        indices : Iterable[int] | None, optional
            If ``None`` (default) then iterate through the entire pixel data,
            otherwise only iterate through the frames specified by `indices`.
        raw : bool, optional
            If ``True`` then yield the decoded pixel data after only
            minimal processing (see the processing section above). If ``False``
            (default) then additional processing may be applied to convert the
            pixel data to it's most commonly used form (such as converting from
            YCbCr to RGB). To yield frames of pixel data with no processing
            whatsoever, use the :meth:`~pydicom.pixels.decoders.base.Decoder.iter_buffer`
            method.
        validate : bool, optional
            If ``True`` (default) then validate the supplied decoding options
            and encoded pixel data prior to decoding, otherwise if ``False``
            no validation will be performed.
        decoding_plugin : str, optional
            The name of the decoding plugin to use when decoding compressed
            pixel data. If no `decoding_plugin` is specified (default) then all
            available plugins will be tried and the result from the first successful
            one yielded. For information on the available plugins for each
            decoder see the :doc:`API documentation</reference/pixels.decoders>`.
        **kwargs
            Optional keyword parameters for controlling decoding are also
            available, please see the :doc:`decoding options documentation
            </guides/decoding/decoder_options>` for more information.

        Yields
        ------
        numpy.ndarray
            A single frame of decoded and reshaped pixel data, with shape:

            * (rows, columns) for single sample data
            * (rows, columns, samples) for multi-sample data

            The :class:`~numpy.dtype` for the array will have an
            :attr:`~numpy.dtype.itemsize` sufficient to contain pixels of at
            least :ref:`bits allocated<bits_allocated>`.

            A writeable :class:`~numpy.ndarray` is returned by default. For
            native transfer syntaxes with ``view_only=True`` a read-only
            :class:`~numpy.ndarray` will be yielded if `src` is immutable.
        dict[str, str | int]
            The :dcm:`Image Pixel<part03/sect_C.7.6.3.html>` module element
            values resulting from the decoding process that describe the array.
            See :meth:`DecodeRunner.pixel_properties()
            <pydicom.pixels.decoders.base.DecodeRunner.pixel_properties>` for the
            possible contents.
        r  r  r4   FTr-  r   r   r   )rY   r   r   r   NrD   )&r   r   r.   r(   r   r!  r   r
   r   rA   r"  r   r#  rS   r$  r  r%  r&  rL   r'  r]   r   r`   r1  r   r   r  rn   rd   r   rQ   rR   rU   r   r   r(  r2  r   )rx   r   r^  r  r  r  r  rH   r   r)  rY   r   rG   r*  r   r   rD   rD   rE   
iter_array  sz   k












zDecoder.iter_array)r^  r  r  c          
      k   s    t | j}|| |jdi | |tttdf | | |r(|	  | j
r?|s?| D ]}||jddfV  q1dS | jrF| j}n| j}|rM|nt|j}|D ]}	|||	|jddfV  qTdS )aa  Yield raw decoded pixel data frames as a buffer-like.

        .. warning::

            This method should only be used by advanced users who understand the
            intricacies of converting raw decoded DICOM pixel data to a usable
            form. It may also require the installation of additional packages to
            perform the actual pixel data decoding (see the :doc:`pixel data
            decompression documentation</guides/user/image_data_handlers>` for more
            information).

        Parameters
        ----------
        src : :class:`~pydicom.dataset.Dataset` | buffer-like | file-like
            Single or multi-frame pixel data as one of the following:

            * :class:`~pydicom.dataset.Dataset`: a dataset containing
              the pixel data to be decoded and the corresponding
              *Image Pixel* module elements.
            * :class:`bytes` | :class:`bytearray` | :class:`memoryview`: the
              encoded (and possibly encapsulated) pixel data to be decoded.
            * :class:`~typing.BinaryIO`: a file-like positioned at the start of the
              pixel data element's value. The position will be returned
              to the starting offset only after all frames have been yielded.

            When `src` is not a :class:`~pydicom.dataset.Dataset` then a number
            of keyword parameters are also required. Please see the
            :doc:`decoding options documentation</guides/decoding/decoder_options>`
            for more information.
        indices : Iterable[int] | None, optional
            If ``None`` (default) then iterate through the entire pixel data,
            otherwise only iterate through the frames specified by `indices`.
        validate : bool, optional
            If ``True`` (default) then validate the supplied decoding options
            and encoded pixel data prior to decoding, otherwise if ``False``
            no validation will be performed.
        decoding_plugin : str, optional
            The name of the decoding plugin to use when decoding compressed
            pixel data. If no `decoding_plugin` is specified (default) then all
            available plugins will be tried and the result from the first successful
            one yielded. For information on the available plugins for each
            decoder see the :doc:`API documentation</reference/pixels.decoders>`.
        **kwargs
            Optional keyword parameters for controlling decoding are also
            available, please see the :doc:`decoding options documentation
            </guides/decoding/decoder_options>` for more information.

        Yields
        -------
        bytes | bytearray | memoryview
            A single frame of decoded pixel data.

            * For natively encoded pixel data when `src` is a buffer-like the
              same type in `src` will be yielded, except if `view_only` is
              ``True`` in which case a :class:`memoryview` on the original
              buffer will be yielded instead. If `src` is a file-like then
              :class:`bytes` will always be yielded.
            * Encapsulated pixel data will be yielded as :class:`bytearray`.

            8-bit pixel data encoded as **OW** using *Explicit VR Big Endian* will
            be yielded as-is and may need byte-swapping. To facilitate this
            an extra byte before the expected start (for an odd `index`) or after
            the expected end (for an even `index`) is yielded if the frame contains
            an odd number of pixels.
        dict[str, str | int]
            The :dcm:`Image Pixel<part03/sect_C.7.6.3.html>` module element
            values resulting from the decoding process that describe the
            decoded frame of pixel data. See :meth:`DecodeRunner.pixel_properties()
            <pydicom.pixels.decoders.base.DecodeRunner.pixel_properties>` for the
            possible contents.
        r  Tr   NrD   )r.   r(   r   r!  r   r
   r   rA   r"  r  r]   r   r   r%  rQ  rR  r2  r   )
rx   r   r^  r  r  r  rH   r   r   r   rD   rD   rE   iter_buffer  s.   
P


zDecoder.iter_buffer)r=   r>   r?   r@   r(   ry   r   rC   rA   r0   r  r   r+  staticmethodr.   r'  r&  r   r   rS  r  r  rR  rQ  r   r   r_  r`  r  rD   rD   r   rE   r  D  s    
	
 (J 
e]_
	
 A
r  )gdcm)zpydicom.pixels.decoders.gdcmr   	pylibjpegz!pydicom.pixels.decoders.pylibjpegr   )pillow)zpydicom.pixels.decoders.pillowr   rb  rd  )rb  rd  )pyjpegls)z pydicom.pixels.decoders.pyjpeglsr   re  rf  )pydicom)zpydicom.pixels.decoders.rler   z3.0c                  C   s   t  D ]`\} }| j}| j }| j }t|t| }d|j d| dg}|d |d|  |d |rO|dd	t
| d |d |d	 |d |d
 d	|| _qdS )z'Override the default Decoder docstring.zA pixel data decoder for *z* - ``z``r  z.. versionadded:: zAvailable decoding plugins: z, .zqPlugin-specific options are given in the :doc:`decoder  options documentation</guides/decoding/decoder_options>`.zeSee the :class:`~pydicom.pixels.decoders.base.Decoder` reference for instance methods and attributes.r   N)_PIXEL_DATA_DECODERSr   r(   
_availablekeys_unavailablelistr   r   r   sortedr@   )decversionaddedr  	availableunavailablepluginsr   rD   rD   rE   _build_decoder_docstrings  s*   





rv  r  c                 C   s8   t | } zt|  d W S  ty   td| j dw )a  Return the pixel data decoder corresponding to `uid`.

    .. versionadded:: 3.0

    +-----------------------------------------------------------------------------+
    | Supported Transfer Syntaxes                                                 |
    +--------------------------------------+----------------------------+---------+
    | Name                                 | UID                        | Version |
    |                                      |                            | added   |
    +======================================+============================+=========+
    | *Implicit VR Little Endian*          | 1.2.840.10008.1.2          | 3.0     |
    +--------------------------------------+----------------------------+---------+
    | *Explicit VR Little Endian*          | 1.2.840.10008.1.2.1        | 3.0     |
    +--------------------------------------+----------------------------+---------+
    | *Deflated Explicit VR Little Endian* | 1.2.840.10008.1.2.1.2.1.99 | 3.0     |
    +--------------------------------------+----------------------------+---------+
    | *Explicit VR Big Endian*             | 1.2.840.10008.1.2.2        | 3.0     |
    +--------------------------------------+----------------------------+---------+
    | *JPEG Baseline 8-bit*                | 1.2.840.10008.1.2.4.50     | 3.0     |
    +--------------------------------------+----------------------------+---------+
    | *JPEG Extended 12-bit*               | 1.2.840.10008.1.2.4.51     | 3.0     |
    +--------------------------------------+----------------------------+---------+
    | *JPEG Lossless P14*                  | 1.2.840.10008.1.2.4.57     | 3.0     |
    +--------------------------------------+----------------------------+---------+
    | *JPEG Lossless SV1*                  | 1.2.840.10008.1.2.4.70     | 3.0     |
    +--------------------------------------+----------------------------+---------+
    | *JPEG-LS Lossless*                   | 1.2.840.10008.1.2.4.80     | 3.0     |
    +--------------------------------------+----------------------------+---------+
    | *JPEG-LS Near Lossless*              | 1.2.840.10008.1.2.4.81     | 3.0     |
    +--------------------------------------+----------------------------+---------+
    | *JPEG2000 Lossless*                  | 1.2.840.10008.1.2.4.90     | 3.0     |
    +--------------------------------------+----------------------------+---------+
    | *JPEG2000*                           | 1.2.840.10008.1.2.4.91     | 3.0     |
    +--------------------------------------+----------------------------+---------+
    | *HTJ2K Lossless*                     | 1.2.840.10008.1.2.4.201    | 3.0     |
    +--------------------------------------+----------------------------+---------+
    | *HTJ2K Lossless RPCL*                | 1.2.840.10008.1.2.4.202    | 3.0     |
    +--------------------------------------+----------------------------+---------+
    | *HTJ2K*                              | 1.2.840.10008.1.2.4.203    | 3.0     |
    +--------------------------------------+----------------------------+---------+
    | *RLE Lossless*                       | 1.2.840.10008.1.2.5        | 3.0     |
    +--------------------------------------+----------------------------+---------+
    r   z2No pixel data decoders have been implemented for 'r   )r(   rk  KeyErrorr   r   )r  rD   rD   rE   get_decoder  s   ,rx  )T)rG   r/   rH   r.   rJ   r/   r  )hr@   collections.abcr   r   r   loggingior   mathr   r   r   typingr   r	   r
   r   numpyr`   r   r   ri  r   pydicom.encapsr   r   pydicom.miscr   pydicom.pixels.commonr   r   r   r   r   rN   pydicom.pixels.processingr   pydicom.pixels.utilsr   r   pydicom.uidr   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r   r-   	getLoggerr=   rS   r  r  r  r   rA   r   ProcessingFunctionr0   rX   rC   rd   rn   ro   ro  rB   r.   r  ImplicitVRLittleEndianDecoderExplicitVRLittleEndianDecoderExplicitVRBigEndianDecoder%DeflatedExplicitVRLittleEndianDecoderJPEGBaseline8BitDecoderadd_pluginsJPEGExtended12BitDecoderJPEGLosslessDecoderJPEGLosslessSV1DecoderJPEGLSLosslessDecoderJPEGLSNearLosslessDecoderJPEG2000LosslessDecoderJPEG2000DecoderHTJ2KLosslessDecoder
add_pluginHTJ2KLosslessRPCLDecoderHTJ2KDecoderRLELosslessDecoderrk  rv  rx  rD   rD   rD   rE   <module>   s8  X
&
$

$/    d       o		

