Bonjour

Voici mon code :
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
 
import imageio
 
def recupererImage(path) :
    im = imageio.imread(path)
    return im
 
def remplaceProche(x,y, image) :
    image[x,y][0] = 0
    image[x,y][1] = 0
    image[x,y][2] = 0
 
    if x-1 > 0 :
        if image[x-1,y][0] > 125 or image[x-1,y][1] > 125 or image[x-1,y][2] > 125 :
            remplaceProche(x-1,y,image)
 
    if x+1 < image.shape[0] :
        if image[x+1,y][0] > 125 or image[x+1,y][1] > 125 or image[x+1,y][2] > 125 :
            remplaceProche(x+1,y,image)
 
    if y-1 > 0 :
        if image[x,y-1][0] > 125 or image[x,y-1][1] > 125 or image[x,y-1][2] > 125 :
            remplaceProche(x,y-1,image)
 
    if y+1 < image.shape[1] :
        if image[x,y+1][0] > 125 or image[x,y+1][1] > 125 or image[x,y+1][2] > 125 :
            remplaceProche(x,y+1,image)
 
def comptePointImg(image) :
    cpt = 0
    # Recuperation de largeur, hauteur, nb composantes
    shape = image.shape
 
    for x in range(0, shape[0]-1) :
        for y in range(0, shape[0]-1) :
            if image[x,y][0] > 125 or image[x,y][1] > 125 or image[x,y][2] > 125 :
                cpt += 1
                remplaceProche(x,y,image)
 
    return cpt
 
def appliFull(path) :
    return comptePointImg(recupererImage(path))
Mon idée étant de de considérer des pixel non blanc si l'un des composant est supérieur à 0 mais j'ai un soucis : RecursionError: maximum recursion depth exceeded while calling a Python object

Ai-je fais une bourde dans mon code ? je débute en python..

Pouvez vous m'indiquer les raisons pour lesquelles cela ne fonctionne pas ? est-ce que c'est simplement puisque ma recursion dure trop longtemps ?

Merci beaucoup !

Respectueusement,
Coquendi