| Server IP : 127.0.0.1 / Your IP : 216.73.216.109 Web Server : Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10 System : Windows NT DESKTOP-E5T4RUN 10.0 build 19045 (Windows 10) AMD64 User : SERVERWEB ( 0) PHP Version : 8.1.10 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/cygwin64/lib/python3.9/site-packages/PIL/__pycache__/ |
Upload File : |
a
h�a= � @ s. d dl Z d dlZd dlZG dd� d�ZeZdS )� Nc @ sf e Zd Zddd�Zdd� Zdd� Zdd � Zd
d� Zdd
� Zdd� Z dd� Z
dd� Zdd� Zdd� Z
dS )�StatNc C sj z |r|� |�| _n
|� � | _W n ty8 || _Y n0 t| jt�sNtd��ttt| j�d ��| _d S )Nz$first argument must be image or list� ) � histogram�h�AttributeError�
isinstance�list� TypeError�range�len�bands)�selfZ
image_or_list�mask� r �1/usr/lib/python3.9/site-packages/PIL/ImageStat.py�__init__ s z
Stat.__init__c C s8 |dd� dkrt |��t| d| �� }t| ||� |S )zCalculate missing attributeN� Z_get)r �getattr�setattr)r
�id�vr r r �__getattr__* s
zStat.__getattr__c C s@ dd� }g }t dt| j�d�D ]}|�|| j|d� �� q|S )z-Get min/max values for each band in the imagec S s: d}d}t d�D ] }| | rt||�}t||�}q||fS )N� r r )r
�min�max)r �n�x�ir r r �minmax6 s
z Stat._getextrema.<locals>.minmaxr r N�r
r r �append)r
r r r r r r �_getextrema3 s
zStat._getextremac
C sB g }t dt| j�d�D ]&}|�t�tj| j||d � �� q|S )z(Get total number of pixels in each layerr r )r
r r r � functools�reduce�operator�add�r
r r r r r � _getcountD s $zStat._getcountc C sR g }t dt| j�d�D ]6}d}t d�D ]}||| j|| 7 }q&|�|� q|S )z#Get sum of all pixels in each layerr r � r )r
r r ZlayerSum�jr r r �_getsumL s zStat._getsumc C sZ g }t dt| j�d�D ]>}d}t d�D ]"}||d t| j|| � 7 }q&|�|� q|S )z+Get squared sum of all pixels in each layerr r r( � )r
r r �floatr )r
r r �sum2r) r r r �_getsum2W s z
Stat._getsum2c C s. g }| j D ]}|�| j| | j| � q
|S )z&Get average pixel level for each layer)r r �sum�countr&