
    nj                         S SK r S SKrS SKJr  \R
                  \l        S rS r\ R                  4S jr
\S:X  a#  \ R                  " \
" \ R                  5      5        gg)    N)gdalc                     [        U 5      R                  5       n/ nU H  nUR                  [        U5      5        M     U$ )N)open	readlinesappendint)filenamelineslutlines       X/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/osgeo_utils/samples/gdal_lut.pyread_lutr   0   s:    N$$&E
C

3t9  J    c                      [        S5        g)Naw  
Usage: gdal_lut.py src_file [-srcband] [dst_file] [-dstband] -lutfile filename
                   [-of format] [-co name=value]...

If dst_file is not specified, the result will be applied back to src_file.
The text file specified with -lutfile should have one line per LUT entry
with just the output pixel value.  Thus a LUT file like:

0
5
11
12
12
13

would map input pixel values 0,1,2,3,4,5 to 0,5,11,12,12,13 respectively.
Values not mapped by the lut file (for instance values 6-255 in the above
case) will be left unaltered.  Sixteen bit (UInt16) output values are
supported as well as luts of more than 256 input values.
   )print r   r   Usager   @   s    		, r   c           	         SnS nS nSnSnS n/ n[         R                  " 5         [         R                  " U 5      n U c  gSnU[        U 5      :  a  X   n	U	S:X  a
  US-   nX   nO{U	S:X  a  US-   nUR	                  X   5        O\U	S:X  a
  US-   nX   nOLU	S:X  a  US-   n[        X   5      nO3U	S:X  a  US-   n[        X   5      nOUc  X   nOUc  X   nO
[        5       $ US-   nU[        U 5      :  a  M  Ub  Uc
  [        5       $ [        U5      n
SnU
 H  nX:  d  M
  UnM     US	:  a!  [        R                  n[         R                  nO [        R                  n[         R                  n[        U
5      S
::  aB  [        R                  " S
5      n[        [        S
[        U
5      5      5       H	  nX   X'   M     OA[        R                  " S5      n[        [        S[        U
5      5      5       H	  nX   X'   M     UR!                  U5      nUc(  [         R"                  " U[         R$                  5      nUnO[         R"                  " U5      nS nUc  ['        SU5        gUR)                  U5      n[         R*                  " U5      nUc  ['        SU-  5        gUc   [         R"                  " U[         R$                  5      nUcf  UR/                  UUR0                  UR2                  SUUS9nUR5                  UR7                  5       5        UR9                  UR;                  5       5        UR)                  U5      n[         R<                  " S5        [        UR2                  5       Hq  nUR?                  SUUR0                  S5      n[        R@                  " UU5      nURC                  USU5        [         R<                  " US-   UR2                  -  5        Ms     S nS ng! [,         a    S n GN.f = f)NGTiff   r   z-ofz-coz-lutfilez-srcbandz-dstband      i   zUnable to open z"%s" driver not registered.)optionsg        g      ?)"r   AllRegisterGeneralCmdLineProcessorlenr   r   r   r   npuint16
GDT_UInt16uint8GDT_BytearangerangeminastypeOpen	GA_Updater   GetRasterBandGetDriverByName	ExceptionCreateRasterXSizeRasterYSizeSetProjectionGetProjectionSetGeoTransformGetGeoTransformTermProgressReadAsArraytake
WriteArray)argvdriver_namesrc_filenamedst_filename
src_band_n
dst_band_nlut_filenamecreate_optionsiargr   max_valentrytcgclookupsrc_dsdst_dssrc_band
dst_driverdst_bandiYsrc_datadst_datas                           r   mainrN   Z   s   KLLJJLN''-D| 	
A
c$i-g%<AA'KE\AA!!$'*JAA7LJAATWJJAATWJ!7L!7L 7NEA c$i-D |3w
 <
 CG?G  }YY__XX]]
 3x33s3C)*AFI + 5!s5#c(+,AFI - ]]2F
 <8<(~.##J/H
 %%k2J+k9:~	YY|T^^<F >&&""""& ' F   !5!5!78""6#9#9#;<##J/H
 	cF&&'''2v/A/A1E7768,Ha,28v'9'99: ( FFA  	F	s   %O! !O10O1__main__)sysnumpyr   osgeor   TermProgress_nocbr3   r   r   r7   rN   __name__exitr   r   r   <module>rV      s\   @   **  4 hh Od zHHT#((^ r   