Bonjour,
Il s´agit de mon premier programme et bien évidement il ne marche pas
J´ai bien lu les consignes sur le titre clair mais comme je ne vois pas d´ou vient mon problème je ne sais pas quoi mettre dans le titre.
Alors voilà la bête:
Le premier fichier.py s´appelle FDKrunning.py et contient:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
import os
from PIL.Image import *
from ProgFDK3 import *
 
#ask picture´s name
Name=input("enter the picture´s name")
 
 
# test the function FDK_evaluation from the module ProgFDK3
FDK_evaluation(Name)
 
os.system("pause")[/I]
Le second fichier ProgFDK3.py contient:
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
 
"""Module ProgFDK3 including the funtion FDK_evaluation"""
 
 
def FDK_evaluation(Name,paramB=100,paramR=79):
 
 """This function evaluate the FDK symptomes on grains
        The first variable contains the name of the picture
        The second the blue parameter which allow to recognize the diseased-grains
         and which is automatically set up to 100 for triticale
        The third variable is the red parameter which allow to recognize our blue background
         and which is automatically set up to 79"""
 
#Load the picture
i_orig = open(Name)
i_trans = open(Name)
 
#Show it
#Image.show(i_orig)
 
# Get the size in pixels of the picture
(largeur, hauteur)= i_orig.size
# initialize the number of pixel from grains and from diseased grains
tot_pix_grains = 0
nb_pix_diseased = 0
 
for x in range(largeur):
    for y in range(hauteur):
    # Here we check the pixel with the coordinates(x,y) from the picture i-orig.
    # The point(0,0) is in the top left-hand corner.
        #getpixel, will get the level of red, green, and blue from the pixel
        (r,g,b) = i_orig.getpixel((x,y))
        # if r>79 we are not looking a pixel in the blue background.
        if r>79:
            #if this pixel is not in the background it is in a grain.
            tot_pix_grains += 1
            # if this pixel present a level of b>100 it is turning white. it is diseased.
            if b>100 :
                  nb_pix_diseased += 1
            #Now we change its color
            (l,m,n) = (204,153,255)
            i_trans.putpixel((x,y),(l,m,n))
 
        else :
        # if r<80 we are looking a pixel in the blue background.    
            #Now we turn it in black
            (l,m,n) = (0,0,0)
            i_trans.putpixel((x,y),(l,m,n))
 
 
 
 
#Image.show(i_trans)            
print("number of grain-pixel =", tot_pix_grains, "number of diseased-grain-pixel =", nb_pix_diseased, "% =", nb_pix_diseased*100/tot_pix_grains)
Et quand je souhaite le lancer j´obtiens la réponse NameError: name 'Name' is not defined pourtant Name est le paramètre de ma fonction et devrait m´être demandé grâce à input donc je ne comprend pas ce qui ne va pas.
Je précise que les deux fichiers.py sont rangés dans le même dossier et qu´un dossier __pycache__ a bien été créé.

Merci pour vos explications !