Bonjour je suis en train de créer ce code python qui permet de filtrer des images à l'aide de filtre moyen. mais j'ai obtenu cet erreur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 Traceback (most recent call last): File "D:\mes doc\python\MeanFilter2\main.py", line 2, in <module> import scipy.io ModuleNotFoundError: No module named 'scipy'Mais en essayant d'installer la bibliothèque scipy à l'aide de "pip install scipy" j'ai obtenu cet erreur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 import numpy as np import scipy.io # Charger l'image radar depuis le fichier .mat image_data = scipy.io.loadmat('image.mat')['image'] # Définir la taille du noyau de filtre de moyenne taille_noyau = 3 # Vous pouvez ajuster cette taille selon vos besoins # Fonction pour appliquer le filtre de moyenne def filtre_moyenne(image, taille_noyau): hauteur, largeur = image.shape image_filtree = np.zeros_like(image) # Parcourir chaque pixel de l'image for i in range(hauteur): for j in range(largeur): # Extraire le voisinage du pixel voisinage = image[max(0, i - taille_noyau // 2):min(hauteur, i + taille_noyau // 2 + 1), max(0, j - taille_noyau // 2):min(largeur, j + taille_noyau // 2 + 1)] # Appliquer le filtre de moyenne image_filtree[i, j] = np.mean(voisinage) return image_filtree # Appliquer le filtre de moyenne sur l'image radar image_filtree = filtre_moyenne(image_data, taille_noyau) # Afficher l'image originale et l'image filtrée (vous pouvez utiliser matplotlib ou une autre bibliothèque pour afficher les images) # Par exemple avec matplotlib : import matplotlib.pyplot as plt plt.subplot(1, 2, 1) plt.imshow(image_data, cmap='gray') plt.title('Image originale') plt.axis('off') plt.subplot(1, 2, 2) plt.imshow(image_filtree, cmap='gray') plt.title('Image filtrée') plt.axis('off') plt.show()
Y'a t'il une solution pour installer scipy ou de la remplacer par une autre méthode pour lire les fichiers .mat sachant que j'ai essayé avec la bibliothèque open cv mais il parait qu'il est impossible de lire les fichiers .mat en utilisant la bibliothèque opencv
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72 (venv) PS D:\mes doc\python\MeanFilter2> pip install scipy Collecting scipy Using cached scipy-1.12.0.tar.gz (56.8 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... error ERROR: Command errored out with exit status 1: command: 'D:\mes doc\python\MeanFilter2\venv\Scripts\python.exe' 'D:\mes doc\python\MeanFilter2\venv\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\SMPS\AppData\Local\Temp\tmptrxdu8ol' cwd: C:\Users\SMPS\AppData\Local\Temp\pip-install-pif7xn5s\scipy_882e7764672c437487e57fcee27ba381 Complete output (23 lines): + meson setup C:\Users\SMPS\AppData\Local\Temp\pip-install-pif7xn5s\scipy_882e7764672c437487e57fcee27ba381 C:\Users\SMPS\AppData\Local\Temp\pip-install-pif7xn5s\scipy_882e7764672c437487e57fcee27ba381\.mesonpy-olh53hf3 -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=C:\Users\SMPS\AppData\Local\Temp\pip-install-pif7xn5s\scipy_882e7764672c437487e57fcee27ba381\.mesonpy-olh53hf3\meson-python-native-file.ini The Meson build system Version: 1.3.2 Source dir: C:\Users\SMPS\AppData\Local\Temp\pip-install-pif7xn5s\scipy_882e7764672c437487e57fcee27ba381 Build dir: C:\Users\SMPS\AppData\Local\Temp\pip-install-pif7xn5s\scipy_882e7764672c437487e57fcee27ba381\.mesonpy-olh53hf3 Build type: native build Project name: scipy Project version: 1.12.0 C compiler for the host machine: gcc (gcc 6.3.0 "gcc (MinGW.org GCC-6.3.0-1) 6.3.0") C linker for the host machine: gcc ld.bfd 2.28 C++ compiler for the host machine: c++ (gcc 6.3.0 "c++ (MinGW.org GCC-6.3.0-1) 6.3.0") C++ linker for the host machine: c++ ld.bfd 2.28 Cython compiler for the host machine: cython (cython 3.0.8) Host machine cpu family: x86 Host machine cpu: x86 Program python found: YES (D:\mes doc\python\MeanFilter2\venv\Scripts\python.exe) Run-time dependency python found: YES 3.10 ..\meson.build:32: WARNING: You are building from source on a 32-bit Python install. SciPy does not provide 32-bit wheels; install 64-bit Python if you are having issues! Program cython found: YES (C:\Users\SMPS\AppData\Local\Temp\pip-build-env-fpyelsy9\overlay\Scripts\cython.EXE) ..\meson.build:45:4: ERROR: Problem encountered: SciPy requires GCC >= 8.0 A full log can be found at C:\Users\SMPS\AppData\Local\Temp\pip-install-pif7xn5s\scipy_882e7764672c437487e57fcee27ba381\.mesonpy-olh53hf3\meson-logs\meson-log.txt ---------------------------------------- WARNING: Discarding https://files.pythonhosted.org/packages/30/85/cdbf2c3c460fe5aae812917866392068a88d02f07de0fe31ce738734c477/scipy-1.12.0.tar.gz#sha256=4bf5abab8a36d20193c698b0f1fc282c1d083c94723902c447e5d2f1780936a3 (from https://pypi.org/simple/scipy/) (requires-python:>=3.9). Command errored out with exit status 1: 'D:\mes doc\doc\THESE\python\MeanFilter2\venv\Scripts\python.exe' 'D:\mes doc\python\MeanFilter2\venv\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\SMPS\AppData\Local\Temp\tmptrxdu8ol' Check the logs for full command output. Using cached scipy-1.11.4.tar.gz (56.3 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... error ERROR: Command errored out with exit status 1: command: 'D:\mes doc\python\MeanFilter2\venv\Scripts\python.exe' 'D:\mes doc\python\MeanFilter2\venv\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\SMPS\AppData\Local\Temp\tmpe2bxjmhd' cwd: C:\Users\SMPS\AppData\Local\Temp\pip-install-pif7xn5s\scipy_49974063178848ce9f7be08084cca911 Complete output (23 lines): + meson setup C:\Users\SMPS\AppData\Local\Temp\pip-install-pif7xn5s\scipy_49974063178848ce9f7be08084cca911 C:\Users\SMPS\AppData\Local\Temp\pip-install-pif7xn5s\scipy_49974063178848ce9f7be08084cca911\.mesonpy-0mnr1_xe -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=C:\Users\SMPS\AppData\Local\Temp\pip-install-pif7xn5s\scipy_49974063178848ce9f7be08084cca911\.mesonpy-0mnr1_xe\meson-python-native-file.ini The Meson build system Version: 1.3.2 Source dir: C:\Users\SMPS\AppData\Local\Temp\pip-install-pif7xn5s\scipy_49974063178848ce9f7be08084cca911 Build dir: C:\Users\SMPS\AppData\Local\Temp\pip-install-pif7xn5s\scipy_49974063178848ce9f7be08084cca911\.mesonpy-0mnr1_xe Build type: native build Project name: SciPy Project version: 1.11.4 C compiler for the host machine: gcc (gcc 6.3.0 "gcc (MinGW.org GCC-6.3.0-1) 6.3.0") C linker for the host machine: gcc ld.bfd 2.28 C++ compiler for the host machine: c++ (gcc 6.3.0 "c++ (MinGW.org GCC-6.3.0-1) 6.3.0") C++ linker for the host machine: c++ ld.bfd 2.28 Cython compiler for the host machine: cython (cython 0.29.37) Host machine cpu family: x86 Host machine cpu: x86 Program python found: YES (D:\mes doc\python\MeanFilter2\venv\Scripts\python.exe) Run-time dependency python found: YES 3.10 ..\meson.build:32: WARNING: You are building from source on a 32-bit Python install. SciPy does not provide 32-bit wheels; install 64-bit Python if you are having issues! Program cython found: YES (C:\Users\SMPS\AppData\Local\Temp\pip-build-env-o76bxoea\overlay\Scripts\cython.EXE) ..\meson.build:45:4: ERROR: Problem encountered: SciPy requires GCC >= 8.0 A full log can be found at C:\Users\SMPS\AppData\Local\Temp\pip-install-pif7xn5s\scipy_49974063178848ce9f7be08084cca911\.mesonpy-0mnr1_xe\meson-logs\meson-log.txt ---------------------------------------- WARNING: Discarding https://files.pythonhosted.org/packages/6e/1f/91144ba78dccea567a6466262922786ffc97be1e9b06ed9574ef0edc11e1/scipy-1.11.4.tar.gz#sha256=90a2b78e7f5733b9de748f589f09225013685f9b218275257f8a8168ededaeaa (from https://pypi.org/simple/scipy/) (requires-python:>=3.9). Command errored out with exit status 1: 'D:\mes doc\doc\MeanFilter2\venv\Scripts\python.exe' 'D:\mes doc\python\MeanFilter2\venv\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\SMPS\AppData\Local\Temp\tmpe2bxjmhd' Check the logs for full command output. Using cached scipy-1.11.3.tar.gz (56.3 MB) ...................
merci d'avance
Partager