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
|
Y=cv2.imread('/content/gdrive/My Drive/Y.png',cv2.IMREAD_GRAYSCALE)
X=cv2.imread('/content/gdrive/My Drive/X.png',cv2.IMREAD_GRAYSCALE)
### max
D=np.zeros([X.shape[0],X.shape[1]],dtype="uint8")
L=[]
for i in range(X.shape[0]) :
for j in range(X.shape[1]) :
D[i][j]=min(X[i][j],Y[i][j])
E=np.zeros([X.shape[0],X.shape[1]],dtype="uint8")
for i in range(X.shape[0]) :
for j in range(X.shape[1]) :
E[i][j]=max(X[i][j],Y[i][j])
M=np.zeros([X.shape[0],X.shape[1]],dtype="uint8") #image median
M1=np.zeros([X.shape[0],X.shape[1]],dtype="uint8")
test=1
mask = np.ones((1, 31)) #element structurant : -----------
while test:
D=cv2.dilate(D,mask)
E=cv2.erode(E,mask)
#M1=max(M,min)
for i in range(X.shape[0]) :
for j in range(X.shape[1]) :
M1[i][j]=max(M[i][j],min(X[i][j],Y[i][j]))
for i in range(X.shape[0]) :
for j in range(X.shape[1]) :
if M1[i][j]==M[i][j] :
test=0
M=M1
io.imshow(M1) # ici est le problème je dois afficher plusieurs image alors si je laisse cette commande elle me donne que le résultat final.
plt.show() |
Partager