files_organisation #5

Merged
Darkan merged 6 commits from files_organisation into master 2022-11-09 08:47:56 +01:00
86 changed files with 165 additions and 297 deletions
.gitignore
.vscode
imageEngine
__pycache__
filters
gray_images
image_test.jpg
images
invert_images
main.py
my_images
#男性 hiro 016 - JUNKTのイラスト - pixiv.jpeg002 wallpaper by mrdmtx - Download on ZEDGE™ _ f370.jpeg16140374-1277-4256-b868-c3e2afa22d92.jpeg48447f61-564c-4117-b0ce-ecddb9b2f523.jpeg5252b97a-f315-4f8d-b90c-61cded685a41.jpeg6e57e80c-01cc-43b4-8869-d8fe002c9d17.jpeg7dd03be6-fc18-4c03-91e5-6d7da4b4a804.jpeg83d01294-7873-4b40-8ccd-3a0fa5180726.jpeg86db3e06-216f-4470-b209-db062275fe42.jpeg892b9be3-4622-4f2f-929b-2b322121fb53.jpeg90455a49-ad7c-43db-a6f2-c7e02629d8a1.jpegAnime Funny Art on Twitter.jpegChristmas Spectre [Twitter lists 彩羽とも].jpegCosplayClass Official Site - Shop Cosplay Costumes Latest & Greatest_.jpegCute.jpgDownload Beautiful Anime Girl, Manga Anime, Anime Art, Zero - Two Darling Render Zero Two PNG Image with No Backgroud - PNGkey_com.pngFond d'écran Chainsaw Man à télécharger HD_4K_1080p - Fond-Ecran-Anime_fr.pngImage about cute in Darling In The Franxx 💕 by _ Pinky_Bubble _ ♥️.jpegJabami Yumeko - Kakegurui - Image by mangajin08 #2390684 - Zerochan Anime Image Board.jpegKerno(カーノ) on Twitter.jpegKitagawa Marin - Sono Bisque Doll wa Koi wo Suru - Image by Lancheu #3572716 - Zerochan Anime Image Board.jpegLiL¥⛧.jpegMakima chainsaw man.jpegMakima.pngMarin Kitagawa Icon.jpegMarin Kitagawa📸🔥.jpegMarin.jpegMary y Yumeko.jpegMegumi Fushiguro.jpegMy Anime For Life.jpegNardack🦋 on Twitter.jpegPin de aiSticker en Stikers en 2022 _ Dibujos kawaii, Personajes de anime, Dibujos bonitos.jpegPinterest.jpegSCROLL.jpegSTE.jpegSteven A_ Starphase - Kekkai Sensen - Mobile Wallpaper by Nngs #2067816 - Zerochan Anime Image Board.jpegTanya Degurechaff.jpegThis one's for Zero Two.jpegTwitter.jpegYoujo Senki wallpaper by MOTOVOh - Download on ZEDGE™ _ c84d.jpegZero two, anime girl, artwork, 480x800 wallpaper.jpegZero_Two.jpegZero_Two.pngZero_Two_1.jpegZero_Two_3.jpegaa8f3d45-e396-48a1-994e-32fab5570483.jpegcouple icon.jpegd51cfc50-f94e-442b-89f9-7aa58b1740b5.jpege1a62b2d-ad82-4737-9b2d-aea11ee5c6ae.jpegffa4cbeb-7827-4c96-998a-0c968324f42a.jpegsaber_alter.jpegtéléchargement.jpegwenay_anime.jpegzero_two_2.jpegɪɴᴄᴏʀʀᴇᴄᴛ ǫᴜᴏᴛᴇs!.jpegПауэр человек бензопила манга.jpegصور بنات انمي.jpegẢnh Anime Đẹp ( 2 ) - Zero Two ( Darling in the FranXX ).jpeg• Wallpaper Power • Chainsaw Man.jpeg⇉𝑻𝑶𝑮𝑨 𝑯𝑰𝑴𝑰𝑲𝑶 ⇉𝑩𝒐𝒌𝒖 𝒏𝒐 𝑯𝒆𝒓𝒐 𝑨𝒄𝒂𝒅𝒆𝒎𝒊𝒂_ _ Dibujos de figuras geometricas, Foto en dibujo, Imagenes de togas.jpegゆうり.png𓏲 𝗠𝗮𝗿𝗶𝗻 𝗞𝗶𝘁𝗮𝗴𝗮𝘄𝗮 𖤐⋆ ࣪.jpeg𝐏𝐨𝐰𝐞𝐫.jpeg𝐦𝐬 𝐌𝐚𝐤𝐢𝐦𝐚.jpeg
re_serie_7.py
sobel
test
new2.jpg

4
.gitignore vendored Normal file

@ -0,0 +1,4 @@
.vscode/
imageEngine/images/
imageEngine/test/
Review

Selon à quel points tes test sont bien écrit tu peux les laisser dans le repo. à toi de voir!

Selon à quel points tes test sont bien écrit tu peux les laisser dans le repo. à toi de voir!
imageEngine/__pycache__/

@ -1,3 +0,0 @@
{
"python.analysis.typeCheckingMode": "basic"
}

@ -0,0 +1,39 @@
from usefull_func import *
from math import sqrt, atan2
#En_cours...
def filtre_canny(img):
def norme_gradient(pixel1, pixel2):
color_x = pixel1[0]
color_y = pixel2[0]
norm = round(sqrt(color_x**2 + color_y**2))
norm = min(norm, 255)
grad = atan2(color_y, color_x)
return norm, grad
def liste_normGrad(im1, im2):
liste = []
for j in range(len(im1)):
ligne = []
for i in range(len(im1[0])):
normGrad = norme_gradient(im1[j][i], im2[j][i])
ligne.append(normGrad)
liste.append(ligne)
return liste
if not is_greyscale(img):
img = greyscale(img)
mat_x = [[-1,0,1]]
mat_y = [[1],[0],[-1]]
#lissage/suppression des bri
img_no_bruit = convolution_gauss(img)
Jx = convolution(img, mat_x)
Jy = convolution(img, mat_y)
normGrad = liste_normGrad(Jx, Jy)
#Suppresion des non-maximum

@ -0,0 +1,16 @@
from usefull_func import *
def filtre_sobel(img):
if not is_greyscale(img):
img = greyscale(img)
mat_x = [[-1,0,1],[-2,0,2],[-1,0,1]]
mat_y = [[-1,-2,-1],[0,0,0],[1,2,1]]
Gx = convolution(img, mat_x)
Gy = convolution(img, mat_y)
filtred_image = application_norme(Gx,Gy)
return filtred_image

@ -0,0 +1,105 @@
from math import sqrt
def greyscale(mat_img):
gray_img = []
for ligne in mat_img:
lig = []
for r,g,b in ligne:
v = int(r*0.2125 + g*0.7154 + b*0.0721)
lig.append((v,)*3)
gray_img.append(lig)
return gray_img
def appliquer_convolution(img, mat, i, j):
somme = 0
for y in range(len(mat)):
for x in range(len(mat[0])):
pixel_i = i - (len(mat[0]) // 2) + x
pixel_j = j - (len(mat) // 2) + y
pix = pixel(img, pixel_i, pixel_j)
somme += pix[0]*mat[y][x]
return min(max(somme,0), 255)
def convolution(mat_img, mat):
return_img = []
for j in range(len(mat_img)):
ligne = []
for i in range(len(mat_img[0])):
val = appliquer_convolution(mat_img, mat, i, j)
ligne.append((val,)*3)
return_img.append(ligne)
return return_img
def is_greyscale(img):
_greyscale = True
for ligne in img:
for r,g,b in ligne:
if not (r==g and g==b):
_greyscale = False
break
if not _greyscale:
break
return _greyscale
def invert(img):
result_image = []
for ligne in img:
result_ligne = []
for r,g,b in ligne:
result_ligne.append((255-r, 255-g, 255-b))
result_image.append(result_ligne)
return result_image
def pixel(img, i, j, default=(0,0,0)):
#i la colone et j la ligne
if 0 <= i < len(img[0]) and 0 <= j < len(img):
return img[j][i]
else:
return default
def reduction_bruit(img, mat, i, j):
somme = 0
for y in range(len(mat)):
for x in range(len(mat[0])):
pixel_i = i - (len(mat[0]) // 2) + x
pixel_j = j - (len(mat) // 2) + y
pix = pixel(img, pixel_i, pixel_j)
somme += pix[0]*mat[y][x]
normalise = round(somme)
return normalise
def convolution_gauss(mat_img):
mat_gauss = [
[2/159, 4/159, 5/159, 4/159,2/159],
[4/159, 9/159,12/159, 9/159,4/159],
[5/159,12/159,15/159,12/159,5/159],
[4/159, 9/159,12/159, 9/159,4/159],
[2/159, 4/159, 5/159, 4/159,2/159]
]
return_img = []
for j in range(len(mat_img)):
ligne = []
for i in range(len(mat_img[0])):
val = reduction_bruit(mat_img, mat_gauss, i, j)
ligne.append((val,)*3)
return_img.append(ligne)
return return_img
def calcul_norme(pixel1, pixel2):
valeur = pixel1[0]**2 + pixel2[0]**2
norm = round(sqrt(valeur))
norm = int(min(norm, 255))
return norm
def application_norme(im_x, im_y):
result_image = []
for j in range(len(im_x)):
ligne = []
for i in range(len(im_x[0])):
pixel1 = im_x[j][i]
pixel2 = im_y[j][i]
norme = calcul_norme(pixel1, pixel2)
ligne.append((norme,)*3)
result_image.append(ligne)
return result_image

Binary file not shown.

Before

(image error) Size: 989 KiB

Binary file not shown.

Before

(image error) Size: 114 B

Binary file not shown.

Before

(image error) Size: 186 KiB

Binary file not shown.

Before

(image error) Size: 98 B

Binary file not shown.

Before

(image error) Size: 548 KiB

Binary file not shown.

Before

(image error) Size: 78 KiB

Binary file not shown.

Before

(image error) Size: 1.4 MiB

1
imageEngine/main.py Normal file

@ -0,0 +1 @@

Binary file not shown.

Before

(image error) Size: 568 KiB

Binary file not shown.

Before

(image error) Size: 95 KiB

Binary file not shown.

Before

(image error) Size: 24 KiB

Binary file not shown.

Before

(image error) Size: 75 KiB

Binary file not shown.

Before

(image error) Size: 106 KiB

Binary file not shown.

Before

(image error) Size: 59 KiB

Binary file not shown.

Before

(image error) Size: 81 KiB

Binary file not shown.

Before

(image error) Size: 78 KiB

Binary file not shown.

Before

(image error) Size: 87 KiB

Binary file not shown.

Before

(image error) Size: 46 KiB

Binary file not shown.

Before

(image error) Size: 86 KiB

Binary file not shown.

Before

(image error) Size: 70 KiB

Binary file not shown.

Before

(image error) Size: 55 KiB

Binary file not shown.

Before

(image error) Size: 164 KiB

Binary file not shown.

Before

(image error) Size: 218 KiB

Binary file not shown.

Before

(image error) Size: 63 KiB

Binary file not shown.

Before

(image error) Size: 190 KiB

Binary file not shown.

Before

(image error) Size: 340 KiB

Binary file not shown.

Before

(image error) Size: 128 KiB

Binary file not shown.

Before

(image error) Size: 158 KiB

Binary file not shown.

Before

(image error) Size: 39 KiB

Binary file not shown.

Before

(image error) Size: 119 KiB

Binary file not shown.

Before

(image error) Size: 138 KiB

Binary file not shown.

Before

(image error) Size: 58 KiB

Binary file not shown.

Before

(image error) Size: 116 KiB

Binary file not shown.

Before

(image error) Size: 112 KiB

Binary file not shown.

Before

(image error) Size: 201 KiB

Binary file not shown.

Before

(image error) Size: 86 KiB

Binary file not shown.

Before

(image error) Size: 237 KiB

Binary file not shown.

Before

(image error) Size: 48 KiB

Binary file not shown.

Before

(image error) Size: 82 KiB

Binary file not shown.

Before

(image error) Size: 53 KiB

Binary file not shown.

Before

(image error) Size: 85 KiB

Binary file not shown.

Before

(image error) Size: 561 KiB

Binary file not shown.

Before

(image error) Size: 96 KiB

Binary file not shown.

Before

(image error) Size: 69 KiB

Binary file not shown.

Before

(image error) Size: 135 KiB

Binary file not shown.

Before

(image error) Size: 46 KiB

Binary file not shown.

Before

(image error) Size: 62 KiB

Binary file not shown.

Before

(image error) Size: 107 KiB

Binary file not shown.

Before

(image error) Size: 100 KiB

Binary file not shown.

Before

(image error) Size: 71 KiB

Binary file not shown.

Before

(image error) Size: 55 KiB

Binary file not shown.

Before

(image error) Size: 31 KiB

Binary file not shown.

Before

(image error) Size: 69 KiB

Binary file not shown.

Before

(image error) Size: 50 KiB

Binary file not shown.

Before

(image error) Size: 57 KiB

Binary file not shown.

Before

(image error) Size: 88 KiB

Binary file not shown.

Before

(image error) Size: 72 KiB

Binary file not shown.

Before

(image error) Size: 1.2 MiB

Binary file not shown.

Before

(image error) Size: 102 KiB

Binary file not shown.

Before

(image error) Size: 79 KiB

@ -1,294 +0,0 @@
import umage as um
from math import sqrt, atan2, sin, cos, pi
def greyscale(mat_img):
gray_img = []
for ligne in mat_img:
lig = []
for r,g,b in ligne:
v = int(r*0.2125 + g*0.7154 + b*0.0721)
lig.append((v,)*3)
gray_img.append(lig)
return gray_img
def convolution(mat_img, mat):
return_img = []
for j in range(len(mat_img)):
ligne = []
for i in range(len(mat_img[0])):
val = appliquer_convolution(mat_img, mat, i, j)
ligne.append((val,)*3)
return_img.append(ligne)
return return_img
def filtre_sobel(img):
def calcul_norme(pixel1, pixel2):
valeur = pixel1[0]**2 + pixel2[0]**2
norm = round(sqrt(valeur))
norm = int(min(norm, 255))
return norm
def application_norme(im_x, im_y):
result_image = []
for j in range(len(im_x)):
ligne = []
for i in range(len(im_x[0])):
pixel1 = im_x[j][i]
pixel2 = im_y[j][i]
norme = calcul_norme(pixel1, pixel2)
ligne.append((norme,)*3)
result_image.append(ligne)
return result_image
if not is_greyscale(img):
img = greyscale(img)
mat_x = [[-1,0,1],[-2,0,2],[-1,0,1]]
mat_y = [[-1,-2,-1],[0,0,0],[1,2,1]]
Gx = convolution(img, mat_x)
Gy = convolution(img, mat_y)
filtred_image = application_norme(Gx,Gy)
return filtred_image
#########################################################################
########################Exercices Supplémentaires########################
#########################################################################
def is_greyscale(img):
_greyscale = True
for ligne in img:
for r,g,b in ligne:
if not (r==g and g==b):
_greyscale = False
break
if not _greyscale:
break
return _greyscale
def invert(img):
result_image = []
for ligne in img:
result_ligne = []
for r,g,b in ligne:
result_ligne.append((255-r, 255-g, 255-b))
result_image.append(result_ligne)
return result_image
def pixel(img, i, j, default=(0,0,0)):
#i la colone et j la ligne
if 0 <= i < len(img[0]) and 0 <= j < len(img):
return img[j][i]
else:
return default
def appliquer_convolution(img, mat, i, j):
somme = 0
for y in range(len(mat)):
for x in range(len(mat[0])):
pixel_i = i - (len(mat[0]) // 2) + x
pixel_j = j - (len(mat) // 2) + y
pix = pixel(img, pixel_i, pixel_j)
somme += pix[0]*mat[y][x]
return min(max(somme,0), 255)
######################################################################
########################Exercices personnelles########################
######################################################################
def convolution_gauss(mat_img):
mat_gauss = [
[2/159, 4/159, 5/159, 4/159,2/159],
[4/159, 9/159,12/159, 9/159,4/159],
[5/159,12/159,15/159,12/159,5/159],
[4/159, 9/159,12/159, 9/159,4/159],
[2/159, 4/159, 5/159, 4/159,2/159]
]
return_img = []
for j in range(len(mat_img)):
ligne = []
for i in range(len(mat_img[0])):
val = reduction_bruit(mat_img, mat_gauss, i, j)
ligne.append((val,)*3)
return_img.append(ligne)
return return_img
def reduction_bruit(img, mat, i, j):
somme = 0
for y in range(len(mat)):
for x in range(len(mat[0])):
pixel_i = i - (len(mat[0]) // 2) + x
pixel_j = j - (len(mat) // 2) + y
pix = pixel(img, pixel_i, pixel_j)
somme += pix[0]*mat[y][x]
normalise = round(somme)
return normalise
def filtre_canny(img):
def norme_gradient(pixel1, pixel2):
color_x = pixel1[0]
color_y = pixel2[0]
norm = round(sqrt(color_x**2 + color_y**2))
norm = min(norm, 255)
grad = atan2(color_y, color_x)
return norm, grad
def liste_normGrad(im1, im2):
liste = []
for j in range(len(im1)):
ligne = []
for i in range(len(im1[0])):
normGrad = norme_gradient(im1[j][i], im2[j][i])
ligne.append(normGrad)
liste.append(ligne)
return liste
if not is_greyscale(img):
img = greyscale(img)
mat_x = [[-1,0,1]]
mat_y = [[1],[0],[-1]]
#lissage/suppression des bri
img_no_bruit = convolution_gauss(img)
Jx = convolution(img, mat_x)
Jy = convolution(img, mat_y)
normGrad = liste_normGrad(Jx, Jy)
#Suppresion des non-maximum
#temp
def norme_gradient(pixel1, pixel2):
color_x = pixel1[0]
color_y = pixel2[0]
norm = round(sqrt(color_x**2 + color_y**2))
norm = min(norm, 255)
grad = atan2(color_y, color_x)
return norm, grad
#temp
def liste_normGrad(im1, im2):
liste = []
for j in range(len(im1)):
ligne = []
for i in range(len(im1[0])):
normGrad = norme_gradient(im1[j][i], im2[j][i])
ligne.append(normGrad)
liste.append(ligne)
return liste
mat_x = [[-1,0,1]]
mat_y = [[1],[0],[-1]]
#temp
#lissage
img = um.load("imageEngine\\images\\valve.png")
img = convolution_gauss(img)
Jx = convolution(img, mat_x)
Jy = convolution(img, mat_y)
normGrad = liste_normGrad(Jx, Jy)
###########
def find_neighbord_norm(mat, i, j, rad):
x = 0
y = 0
if sin(pi/8) <= abs(sin(rad)):
y = 1
if cos(3*pi/8)>abs(cos(rad)):
x = 1
norm_pix1 = -1
norm_pix2 = -1
if 0 <= j-y < len(mat):
if 0 <= i-x < len(mat[0]):
norm_pix1 = mat[j-y][i-x][0]
if 0 <= j+y < len(mat):
if 0 <= i+x < len(mat[0]):
norm_pix2 = mat[j+y][i+x][0]
return norm_pix1, norm_pix2
def delete_pixel(mat_img, mat):
img_to_return = []
for j in range(len(mat)):
ligne = []
for i in range(len(mat[0])):
rad = mat[j][i][1]
norms = find_neighbord_norm(mat, i, j, rad)
if rad < norms[0] or rad < norms[1]:
ligne.append((0,)*3)
else:
ligne.append(mat_img[j][i])
img_to_return.append(ligne)
return img_to_return
"""
def hysteresis(mat_img, mat_norm, Th):
Tl = Th / 2
mat_img = yesOrNo(mat_img, Th, Tl)
result_image = []
for j in range(len(mat_img)):
ligne = []
for i in range(len(mat_img[0])):
rad = mat_norm[j][i][1]
color1, color2 = find_neighbord_pixel(mat_img, i, j, rad+(pi/2))
if color1 == 255 or color2 == 255:
ligne.append((255,)*3)
else:
ligne.append((0,)*3)
result_image.append(ligne)
return result_image
def find_neighbord_pixel(mat_image, i, j, rad):
x = 0
y = 0
if sin(pi/8) <= abs(sin(rad)):
y = 1
if cos(3*pi/8)>abs(cos(rad)):
x = 1
color_pix1 = 0
color_pix2 = 0
if 0 <= j-y < len(mat_image):
if 0 <= i-x < len(mat_image[0]):
color_pix1 = mat_image[j-y][i-x][0]
if 0 <= j+y < len(mat_image):
if 0 <= i+x < len(mat_image[0]):
color_pix2 = mat_image[j+y][i+x][0]
return color_pix1, color_pix2
def yesOrNo(mat_img, Th, Tl):
result_image = []
for j in range(len(mat_img)):
ligne = []
for i in range(len(mat_img[0])):
pix = mat_img[j][i]
if Th <= pix[0]:
ligne.append((255,)*3)
elif pix[0] < Tl:
ligne.append((0,)*3)
else:
ligne.append(pix)
result_image.append(ligne)
return result_image
zt_no_maxima = delete_pixel(img, normGrad)
zt_hysteresis = hysteresis(zt_no_maxima, normGrad, 200)
um.save(zt_hysteresis, "imageEngine\\test\\valve", "png")
"""

Binary file not shown.

Before

(image error) Size: 392 KiB

Binary file not shown.

Before

(image error) Size: 1.3 KiB

Binary file not shown.

Before

(image error) Size: 480 KiB

Binary file not shown.

Before

(image error) Size: 56 KiB

Binary file not shown.

Before

(image error) Size: 312 KiB

Binary file not shown.

Before

(image error) Size: 215 KiB

BIN
new2.jpg

Binary file not shown.

Before

(image error) Size: 134 KiB