o
    e	                     @   s   d dl Zd dlZd dlmZmZmZmZmZ d dl	m
Z
 ed ejdddd Zd	d
 Zdd Zdd Zdd Zdd Zdd Zejdg dejdejejejejgdd ZdS )    N)imreadimsave
use_pluginreset_pluginsplugin_order)testingZ	SimpleITKT)Zautousec                   c   s    t d dV  t  dS )z%Ensure that SimpleITK plugin is used.	simpleitkN)r   r    r	   r	   OD:\Projects\ConvertPro\env\Lib\site-packages\skimage/io/tests/test_simpleitk.pyuse_simpleitk_plugin   s   
r   c                  C   sF   t  } | d d dksJ | d d dksJ | d d dks!J d S )Nr   r   r   r   Zimread_collection)r   )orderr	   r	   r
   test_prefered_plugin   s   r   c                  C   s`   t tddd} | jdksJ | jtjksJ t tddd} t| jtjd v s.J d S )Nzdata/color.pngT)Zas_gray   zdata/camera.pngZ
AllInteger)	r   r   fetchndimdtypenpfloat64Zsctype2char	typecodes)imgr	   r	   r
   test_imread_as_gray   s
   r   c                  C   s8   t d} d| d d d< ttd}t j||  d S )N
   r      r   zdata/checker_bilevel.png)r   Zzerosr   r   r   Zassert_array_equalexpectedr   r	   r	   r
   test_bilevel#   s   
r   c                   C   s>   t t ttd W d    d S 1 sw   Y  d S )Nzdata/truncated.jpg)pytestZraisesRuntimeErrorr   r   r   r	   r	   r	   r
   test_imread_truncated_jpg+   s   "r   c                  C   sD   t td} ttd}t |jt jsJ t j||  d S )Ndata/chessboard_GRAY_U8.npyzdata/chessboard_GRAY_U16.tif)	r   loadr   r   r   
issubdtyper   uint16assert_array_almost_equalr   r	   r	   r
   test_imread_uint160   s   r%   c                  C   s0   t td} ttd}t j||  d S )Nr    zdata/chessboard_GRAY_U16B.tif)r   r!   r   r   r   r$   r   r	   r	   r
   test_imread_uint16_big_endian7   s   r&   shape)r   )r   r      )r   r      r   c                 C   sx   t |t jrt j}nt j}t j||j||jdt | |d}|	| }|d }t
|| t|}t j|| d S )NT)Zendpointnumr   zroundtrip.mha)r   r"   ZfloatingZfinfoZiinfoZlinspaceminmaxprodZreshaper   r   r   r$   )r'   r   Ztmp_pathZ	info_funcr   	file_pathactualr	   r	   r
   test_imsave_roundtrip=   s   

r0   )numpyr   r   Z
skimage.ior   r   r   r   r   Zskimage._sharedr   ZimportorskipZfixturer   r   r   r   r   r%   r&   markZparametrizeZuint8r#   Zfloat32r   r0   r	   r	   r	   r
   <module>   s     


	