Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
teaching:progappchim:analyse_images [2014/02/11 06:44] – créée villersd | teaching:progappchim:analyse_images [2021/03/09 11:25] (Version actuelle) – villersd | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
====== Analyse d' | ====== Analyse d' | ||
- | En préparation. Utilisation des librairies | + | Le traitement d' |
+ | |||
+ | ===== Utilisation | ||
+ | <note tip>La librairie [[http:// | ||
+ | |||
+ | ==== Exemple de base ==== | ||
+ | Télécharger l' | ||
+ | <code python image_import-02.py> | ||
+ | # | ||
+ | # -*- coding: utf-8 -*- | ||
+ | """ | ||
+ | show jpg image | ||
+ | image jpg : https:// | ||
+ | pillow : http:// | ||
+ | """ | ||
+ | from PIL import Image | ||
+ | # install python3 module | ||
+ | |||
+ | # Load the image file | ||
+ | img = Image.open('/ | ||
+ | img.show() | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Exemple avec traitement numérique ==== | ||
+ | |||
+ | Voici un exemple de lecture d'une image, de conversion en monochrome et ensuite en tableau de données numériques de NumPy. Une transformée de Fourier bidimensionnel est effectuée, ainsi que quelques autres traitements, | ||
+ | |||
+ | <code python FFT-structures_2D_01.py> | ||
+ | #! / | ||
+ | # -*- coding: utf-8 -*- | ||
+ | """ | ||
+ | Digital Image processing with PIL | ||
+ | |||
+ | """ | ||
+ | # sources & refs : http:// | ||
+ | # http:// | ||
+ | # http:// | ||
+ | # http:// | ||
+ | |||
+ | import PIL | ||
+ | import Image | ||
+ | import numpy as np | ||
+ | import matplotlib.pyplot as plt | ||
+ | |||
+ | dirfile="" | ||
+ | # | ||
+ | filename=" | ||
+ | im = Image.open(str(dirfile+filename)) | ||
+ | im = im.convert(' | ||
+ | im.show() | ||
+ | data = np.asarray(im) # a is readonly | ||
+ | print type(data), data.ndim, data.shape, data.dtype | ||
+ | datafft = abs(np.fft.rfft2(data)) | ||
+ | datafft[0, 0] = 0 # remove DC component for visualization | ||
+ | print type(datafft), | ||
+ | plt.imshow(np.abs(np.fft.fftshift(datafft)), | ||
+ | plt.show() | ||
+ | plt.imshow(np.abs(np.fft.fftshift(datafft))[192: | ||
+ | plt.show() | ||
+ | im2 = Image.fromarray(datafft) | ||
+ | im2.show() | ||
+ | im2.save(' | ||
+ | </ | ||
+ | |||
+ | L' | ||
+ | |||
+ | <note tip>Pour approfondir l' | ||
+ | |||
+ | ==== Références ==== | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | |||
+ | ===== Scikit-image ===== | ||
+ | * Voir la galerie d' | ||
+ | |||
+ | ===== OpenCV ===== | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | |||
+ | Références diverses : | ||
+ | * [[http:// | ||
+ | |||
+ | ===== pymaging ===== | ||
+ | * [[https:// | ||