CoolFace
Apppublic

forestaiUs/treeextraction-ndvi

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes
image_processing.cpython-310.pyc28 linesDownload Raw Back to __pycache__
1o

2&�hs�@sHddlZddlZddlZddlZddlmZmZmZddl	Z	dd�Z3dS)�N)�Image�ImageEnhance�ImageFilterc4Cs zpt�d|���t�|�}|jdkr|�d�}t�|�}t�	|tj5�}t�|dd�}t�|dtj
tjdd�}t�|dd	�}t�d6tj�}t�|tj|�}	t�|	�}7t��j�d�}tj�||�}|8�|�t�d|���|WSty�}
zt�d
t|
����tdt|
�����d}
~
ww)ax9    Process the input image for geospatial analysis:10    - Convert to grayscale11    - Apply threshold to highlight features12    - Apply noise reduction13    - Apply edge detection14    15    Args:16        image_path (str): Path to the input image17        output_folder (str): Directory to save processed images18        19    Returns:20        str: Path to the processed image21    zProcessing image: �RGB)�rr�����2�)�rz_processed.pngzImage processing complete: zError in image processing: zImage processing failed: N)�logging�infor�open�mode�convert�np�array�cv2�cvtColor�COLOR_RGB2GRAY�GaussianBlur�adaptiveThreshold�ADAPTIVE_THRESH_GAUSSIAN_C�THRESH_BINARY_INV�Canny�ones�uint8�morphologyEx�MORPH_CLOSE�	fromarray�uuid�uuid4�hex�os�path�join�save�	Exception�error�str)�22image_path�
output_folder�imgZ	img_array�grayZblurred�thresh�edges�kernel�cleanedZ
processed_imgZprocessed_filename�output_path�e�r5�S/Users/dynamicpacific/Dropbox/DEV/ForestAI-TreeExtraction/utils/image_processing.py�
process_images423242526�2728��r7)r$r!r
�numpyr�PILrrrrr7r5r5r5r6�<module>s