From 81de032f26d477a407d8e26fb99da1b0da0688d4 Mon Sep 17 00:00:00 2001 From: Justine Date: Thu, 31 Jan 2019 13:03:06 +0100 Subject: [PATCH] Ajout de l'application --- Python/Application/ColorObject.py | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Python/Application/Contour.py | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Python/Application/FondNoir.png | Bin 0 -> 29104 bytes Python/Application/Gradient.py | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Python/Application/ImageComponents.py | 37 +++++++++++++++++++++++++++++++++++++ Python/Application/Parameters.py | 8 ++++++++ Python/Application/ShapeDetection.py | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Python/Application/Skeleton2.py | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Python/Application/Test.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ Python/Application/Threshold.py | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Python/Application/couleur.png | Bin 0 -> 484767 bytes Python/Application/main.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ Python/B.png | Bin 266340 -> 0 bytes Python/Blue.png | Bin 7831 -> 0 bytes Python/BlueDrone.png | Bin 181407 -> 0 bytes Python/CornersEdgesFleches.png | Bin 402760 -> 0 bytes Python/CornersFleches.png | Bin 378170 -> 0 bytes Python/Debut/B.png | Bin 0 -> 266340 bytes Python/Debut/Blue.png | Bin 0 -> 7831 bytes Python/Debut/BlueDrone.png | Bin 0 -> 181407 bytes Python/Debut/CornersEdgesFleches.png | Bin 0 -> 402760 bytes Python/Debut/CornersFleches.png | Bin 0 -> 378170 bytes Python/Debut/G-RGB.png | Bin 0 -> 260425 bytes Python/Debut/Green.png | Bin 0 -> 9092 bytes Python/Debut/GreenDrone.png | Bin 0 -> 173584 bytes Python/Debut/ImageComponents.py | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Python/Debut/ImageDrone.png | Bin 0 -> 441882 bytes Python/Debut/R-RGB.png | Bin 0 -> 260151 bytes Python/Debut/RGB_Bebop.png | Bin 0 -> 304380 bytes Python/Debut/Red.png | Bin 0 -> 7858 bytes Python/Debut/RedDrone.png | Bin 0 -> 176079 bytes Python/Debut/Total.png | Bin 0 -> 67560 bytes Python/Debut/TotalMedium.png | Bin 0 -> 67662 bytes Python/Debut/cornerDetectio,.png | Bin 0 -> 381345 bytes Python/Debut/couleur.png | Bin 0 -> 484767 bytes Python/Debut/couleur2.png | Bin 0 -> 503525 bytes Python/Debut/flecheBleue.png | Bin 0 -> 285618 bytes Python/Debut/flecheRouge.png | Bin 0 -> 277867 bytes Python/Debut/flecheVerte.png | Bin 0 -> 275393 bytes Python/Debut/fleches.png | Bin 0 -> 31959 bytes Python/Debut/test.png | Bin 0 -> 13882 bytes Python/Debut/test.txt | 0 Python/Documentation/ROScheatsheet.pdf | Bin 0 -> 439551 bytes Python/Documentation/opencv-python-tutroals.pdf | Bin 0 -> 4771613 bytes Python/Documentation/opencv_cheatsheet.pdf | Bin 0 -> 287007 bytes Python/Documentation/opencv_python_cheatsheet | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Python/G-RGB.png | Bin 260425 -> 0 bytes Python/Green.png | Bin 9092 -> 0 bytes Python/GreenDrone.png | Bin 173584 -> 0 bytes Python/ImageComponents.py | 97 ------------------------------------------------------------------------------------------------- Python/ImageDrone.png | Bin 441882 -> 0 bytes Python/PreProcessing/Filter.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ Python/PreProcessing/couleur.png | Bin 0 -> 484767 bytes Python/R-RGB.png | Bin 260151 -> 0 bytes Python/RGB_Bebop.png | Bin 304380 -> 0 bytes Python/Red.png | Bin 7858 -> 0 bytes Python/RedDrone.png | Bin 176079 -> 0 bytes Python/Total.png | Bin 67560 -> 0 bytes Python/TotalMedium.png | Bin 67662 -> 0 bytes Python/cornerDetectio,.png | Bin 381345 -> 0 bytes Python/couleur.png | Bin 484767 -> 0 bytes Python/couleur2.png | Bin 503525 -> 0 bytes Python/flecheBleue.png | Bin 285618 -> 0 bytes Python/flecheRouge.png | Bin 277867 -> 0 bytes Python/flecheVerte.png | Bin 275393 -> 0 bytes Python/fleches.png | Bin 31959 -> 0 bytes Python/test.png | Bin 13882 -> 0 bytes Python/test.txt | 0 68 files changed, 850 insertions(+), 97 deletions(-) create mode 100644 Python/Application/ColorObject.py create mode 100644 Python/Application/Contour.py create mode 100644 Python/Application/FondNoir.png create mode 100644 Python/Application/Gradient.py create mode 100644 Python/Application/ImageComponents.py create mode 100644 Python/Application/Parameters.py create mode 100644 Python/Application/ShapeDetection.py create mode 100644 Python/Application/Skeleton2.py create mode 100644 Python/Application/Test.py create mode 100644 Python/Application/Threshold.py create mode 100644 Python/Application/couleur.png create mode 100644 Python/Application/main.py delete mode 100644 Python/B.png delete mode 100644 Python/Blue.png delete mode 100644 Python/BlueDrone.png delete mode 100644 Python/CornersEdgesFleches.png delete mode 100644 Python/CornersFleches.png create mode 100644 Python/Debut/B.png create mode 100644 Python/Debut/Blue.png create mode 100644 Python/Debut/BlueDrone.png create mode 100644 Python/Debut/CornersEdgesFleches.png create mode 100644 Python/Debut/CornersFleches.png create mode 100644 Python/Debut/G-RGB.png create mode 100644 Python/Debut/Green.png create mode 100644 Python/Debut/GreenDrone.png create mode 100644 Python/Debut/ImageComponents.py create mode 100644 Python/Debut/ImageDrone.png create mode 100644 Python/Debut/R-RGB.png create mode 100644 Python/Debut/RGB_Bebop.png create mode 100644 Python/Debut/Red.png create mode 100644 Python/Debut/RedDrone.png create mode 100644 Python/Debut/Total.png create mode 100644 Python/Debut/TotalMedium.png create mode 100644 Python/Debut/cornerDetectio,.png create mode 100644 Python/Debut/couleur.png create mode 100644 Python/Debut/couleur2.png create mode 100644 Python/Debut/flecheBleue.png create mode 100644 Python/Debut/flecheRouge.png create mode 100644 Python/Debut/flecheVerte.png create mode 100644 Python/Debut/fleches.png create mode 100644 Python/Debut/test.png create mode 100644 Python/Debut/test.txt create mode 100644 Python/Documentation/ROScheatsheet.pdf create mode 100644 Python/Documentation/opencv-python-tutroals.pdf create mode 100644 Python/Documentation/opencv_cheatsheet.pdf create mode 100644 Python/Documentation/opencv_python_cheatsheet delete mode 100644 Python/G-RGB.png delete mode 100644 Python/Green.png delete mode 100644 Python/GreenDrone.png delete mode 100644 Python/ImageComponents.py delete mode 100644 Python/ImageDrone.png create mode 100644 Python/PreProcessing/Filter.py create mode 100644 Python/PreProcessing/couleur.png delete mode 100644 Python/R-RGB.png delete mode 100644 Python/RGB_Bebop.png delete mode 100644 Python/Red.png delete mode 100644 Python/RedDrone.png delete mode 100644 Python/Total.png delete mode 100644 Python/TotalMedium.png delete mode 100644 Python/cornerDetectio,.png delete mode 100644 Python/couleur.png delete mode 100644 Python/couleur2.png delete mode 100644 Python/flecheBleue.png delete mode 100644 Python/flecheRouge.png delete mode 100644 Python/flecheVerte.png delete mode 100644 Python/fleches.png delete mode 100644 Python/test.png delete mode 100644 Python/test.txt diff --git a/Python/Application/ColorObject.py b/Python/Application/ColorObject.py new file mode 100644 index 0000000..fcf44ea --- /dev/null +++ b/Python/Application/ColorObject.py @@ -0,0 +1,76 @@ +import cv2 +import numpy as np +from Parameters import * + +def IsolateObject(frame ,Lower, Upper): + hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) + mask = cv2.inRange(hsv, Lower, Upper) + kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(5,5)) + mask = cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernel) + res = cv2.bitwise_and(frame,frame, mask= mask) + return mask, res + +def ColorDisplayResults(liste, nb): + for i in range (0, len(liste)): + if i == 0: + titre = 'mask'+str(nb) + else: + titre = 'res'+str(nb) + cv2.imshow(titre, liste[i]) + return + +def CombineColors(color1, color2): + mask = cv2.bitwise_or(color1[0], color2[0]) + res = cv2.bitwise_or(color1[1], color2[1]) + return mask, res + +def ColorChoiceProcessing(image, choix): + if choix == '1': + blueMask, blueRes = IsolateObject(image, LowerBlue, UpperBlue) + return [blueMask, blueRes] + elif choix == '2': + greenMask, greenRes = IsolateObject(image, LowerGreen, UpperGreen) + return [greenMask, greenRes] + elif choix == '3': + redMask, redRes = IsolateObject(image, LowerRed, UpperRed) + return[redMask, redRes] + elif choix == '4': + blue = ColorChoiceProcessing(image, '1') + green = ColorChoiceProcessing(image, '2') + bgMask, bgRes = CombineColors(blue, green) + return [bgMask, bgRes] + elif choix == '5': + blue = ColorChoiceProcessing(image, '1') + red = ColorChoiceProcessing(image, '3') + brMask, brRes = CombineColors(blue, red) + return [brMask, brRes] + elif choix == '6': + red = ColorChoiceProcessing(image, '3') + green = ColorChoiceProcessing(image, '2') + rgMask, rgRes = CombineColors(red, green) + return [rgMask, rgRes] + elif choix == '7': + bg = ColorChoiceProcessing(image, '4') + red = ColorChoiceProcessing(image, '3') + bgrMask, bgrRes = CombineColors(bg, red) + return [bgrMask, bgrRes] + else: + return + +def ColorChoice() : + image = None + print('\t\tFind Color Object Menu\n') + while (image is None): + image = str(raw_input('\tImage to use ? By default couleur.png \n')) + if not image: + image = 'couleur.png' + image = cv2.imread(str(image)) + print ('\t1. Blue\n\t2. Green\n\t3. Red\n\t4. Blue Green\n\t5. Blue Red\n\t6. Red Green\n\t7. Blue Green Red\n') + choix = raw_input('\n\tMultiple choices possible\n') + for i in range (0, len(choix)): + liste = ColorChoiceProcessing(image, choix[i]) + if liste : + ColorDisplayResults(liste,choix[i]) + cv2.waitKey(0) + cv2.destroyAllWindows() + return diff --git a/Python/Application/Contour.py b/Python/Application/Contour.py new file mode 100644 index 0000000..83115fb --- /dev/null +++ b/Python/Application/Contour.py @@ -0,0 +1,130 @@ +import cv2 +import numpy as np +import numpy as np +import cv2 + +def FindContours(img): + imgray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) + #cv2.imshow("Gray", imgray) + ret,thresh = cv2.threshold(imgray,127,255,0) + #cv2.imshow("threshold", thresh) + _,contours,hierarchy = cv2.findContours(thresh, 1, 2) + return contours + +def FindCenterofMass(contours): + liste = [] + area = [] + centerMass = [] + for i in range (0,len(contours)): + cnt = contours[i] + #print cnt + M = cv2.moments(cnt) + area.append(cv2.contourArea(cnt)) + tmp = cv2.contourArea(cnt) + if (M['m00'] != 0) and (tmp > 1000): + cx = int(M['m10']/M['m00']) + cy = int(M['m01']/M['m00']) + centerMass.append((cx,cy)) + else: + liste.append(i) + return liste, area, centerMass + + + +def CleanContours(img): + contours = FindContours(img) + liste, _, _ = FindCenterofMass(contours) + for j in range (0,len(liste)): + a = liste[j] + if (a < len(contours)): + contours.pop(a) + return contours + +def DrawBoundingBox(img): + contours = FindContours(img) + for cnt in contours: + x,y,w,h = cv2.boundingRect(cnt) + img = cv2.rectangle(img,(x,y),(x+w,y+h),(0,255,0),2) + cv2.imshow('Bounding Box', img) + return img + +def DrawEnclosingCircle(img): + contours = FindContours(img) + for cnt in contours: + (x,y),radius = cv2.minEnclosingCircle(cnt) + center = (int(x),int(y)) + radius = int(radius) + img = cv2.circle(img,center,radius,(0,255,0),2) + cv2.imshow('Enclosing Circle', img) + return img + +def DrawContours(img, contours, titre): + img = cv2.drawContours(img, contours, -1, (0,255,0), 3) + cv2.imshow(titre, img) + return img + +def DrawCenterofMass(img): + contours = FindContours(img) + _, _, centerMass = FindCenterofMass(contours) + for x, y in centerMass: + img=cv2.circle(img, (x,y), 10, (124,255,255), 1) + cv2.imshow('Center of Mass', img) + return img + +def DrawArea(img): + contours = CleanContours(img) + img = cv2.drawContours(img, contours, -1, (255, 0, 0), cv2.FILLED) + cv2.imshow('Area', img) + return img + +def ContourChoiceProcessing(img, choice): + if choice == '1': + contours = FindContours(img) + img = DrawContours(img, contours, 'Contours') + return img + elif choice == '2': + contours = CleanContours(img) + img = DrawContours(img, contours, 'Clean Contours') + return img + elif choice == '3': + img = DrawCenterofMass(img) + return img + elif choice == '4': + img = DrawArea(img) + return img + elif choice == '5': + img = ContourChoiceProcessing(img, '2') + img = DrawCenterofMass(img) + return img + elif choice == '6': + img = DrawArea(img) + img = DrawCenterofMass(img) + return img + elif choice == '7': + img = DrawBoundingBox(img) + return img + elif choice == '8': + img = DrawEnclosingCircle(img) + return img + else: + return + +def ContourChoice(): + image = None + img = None + print('\t\tContours Features Menu\n') + while (image is None): + image = str(raw_input('\tImage to use? By default couleur.png \n')) + if not image: + image = 'couleur.png' + image = cv2.imread(str(image)) + print ('\t1. Contours\n\t2. Clean Contours\n\t3. Center of Mass\n\t4. Area\n\t5. Contours + Center of Mass\n\t6. Area + Center of Mass\n\t7. Bounding Box\n\t8. Enclosing Circle\n') + choix = raw_input('\n\tMultiple choices possible\n') + for i in range (0, len(choix)): + img = image.copy() + img = ContourChoiceProcessing(img, choix[i]) + if img is not None: + cv2.waitKey(0) + cv2.destroyAllWindows() + return + diff --git a/Python/Application/FondNoir.png b/Python/Application/FondNoir.png new file mode 100644 index 0000000..01295d6 Binary files /dev/null and b/Python/Application/FondNoir.png differ diff --git a/Python/Application/Gradient.py b/Python/Application/Gradient.py new file mode 100644 index 0000000..0f42a73 --- /dev/null +++ b/Python/Application/Gradient.py @@ -0,0 +1,73 @@ +import cv2 +import numpy as np +from matplotlib import pyplot as plt +img = cv2.imread('couleur.png',0) + +def Everything (img): + laplacian = cv2.Laplacian(img,cv2.CV_64F) + sobelx = cv2.Sobel(img,cv2.CV_64F,1,0,ksize=5) + sobely = cv2.Sobel(img,cv2.CV_64F,0,1,ksize=5) + plt.subplot(2,2,1),plt.imshow(img,cmap = 'gray') + plt.title('Original'), plt.xticks([]), plt.yticks([]) + plt.subplot(2,2,2),plt.imshow(laplacian,cmap = 'gray') + plt.title('Laplacian'), plt.xticks([]), plt.yticks([]) + plt.subplot(2,2,3),plt.imshow(sobelx,cmap = 'gray') + plt.title('Sobel X'), plt.xticks([]), plt.yticks([]) + plt.subplot(2,2,4),plt.imshow(sobely,cmap = 'gray') + plt.title('Sobel Y'), plt.xticks([]), plt.yticks([]) + plt.show() + return laplacian + +def Laplacian(img): + laplacian = cv2.Laplacian(img,cv2.CV_64F) + plt.plot,plt.imshow(laplacian,cmap = 'gray') + plt.title('Laplacian'), plt.xticks([]), plt.yticks([]) + plt.show() + return laplacian + +def SobelX(img): + sobelx = cv2.Sobel(img,cv2.CV_64F,1,0,ksize=5) + plt.plot,plt.imshow(sobelx,cmap = 'gray') + plt.title('Sobel X'), plt.xticks([]), plt.yticks([]) + plt.show() + return sobelx + +def SobelY(img): + sobely = cv2.Sobel(img,cv2.CV_64F,0,1,ksize=5) + plt.plot,plt.imshow(sobely,cmap = 'gray') + plt.title('Sobel Y'), plt.xticks([]), plt.yticks([]) + plt.show() + return sobely + +def GradientChoiceProcessing(img, choice): + if choice == '1': + img = Laplacian(img) + return img + elif choice == '2': + img = SobelX(img) + return img + elif choice == '3': + img = SobelY(img) + return img + elif choice == '4': + img = Everything(img) + return img + else: + return + + +def GradientChoice() : + image = None + print('\t\tGradient Menu\n') + while (image is None): + image = str(raw_input('\tImage to use? By default couleur.png \n')) + if not image: + image = 'couleur.png' + image = cv2.imread(str(image), 0) + print ('\t1. Laplacian\n\t2. Sobel X\n\t3. Sobel Y\n\t4. Everything\n') + choice = raw_input('\n\tMultiple choices possible\n') + for i in range (0, len(choice)): + img = image.copy() + img = GradientChoiceProcessing(img, choice[i]) + return + diff --git a/Python/Application/ImageComponents.py b/Python/Application/ImageComponents.py new file mode 100644 index 0000000..3cc6e90 --- /dev/null +++ b/Python/Application/ImageComponents.py @@ -0,0 +1,37 @@ +import cv2 +import numpy as np +from matplotlib import pyplot as plt + +def Corners(): + image = None + while (image is None): + image = str(raw_input('\tImage to use ? By default couleur.png \n')) + if not image: + image = 'couleur.png' + image = cv2.imread(str(image)) + img = image.copy() + gray= cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) + gray = np.float32(gray) + dst = cv2.cornerHarris(gray, 5, 5, 0.15) + dst = cv2.dilate(dst, None) + img[dst>0.01*dst.max()] = [0,0,255] + cv2.imshow('dst', img) + cv2.waitKey(0) + cv2.destroyAllWindows() + return + +def Edges(): + image = None + while (image is None): + image = str(raw_input('\tImage to use ? By default couleur.png \n')) + if not image: + image = 'couleur.png' + image = cv2.imread(str(image)) + img = image.copy() + edges = cv2.Canny(img, 100, 200) + plt.subplot(121),plt.imshow(img,cmap='gray') + plt.title('Original Image'), plt.xticks([]), plt.yticks([]) + plt.subplot(122),plt.imshow(edges,cmap = 'gray') + plt.title('Edge Image'), plt.xticks([]), plt.yticks([]) + plt.show() + return diff --git a/Python/Application/Parameters.py b/Python/Application/Parameters.py new file mode 100644 index 0000000..066dab3 --- /dev/null +++ b/Python/Application/Parameters.py @@ -0,0 +1,8 @@ +import numpy as np + +LowerBlue = np.array([102,50,50]) +UpperBlue = np.array([107,255,255]) +LowerRed = np.array([0,50,50]) +UpperRed = np.array([11,255,255]) +LowerGreen = np.array([60,50,50]) +UpperGreen = np.array([80, 255, 255]) diff --git a/Python/Application/ShapeDetection.py b/Python/Application/ShapeDetection.py new file mode 100644 index 0000000..b869f58 --- /dev/null +++ b/Python/Application/ShapeDetection.py @@ -0,0 +1,67 @@ +import cv2 +import numpy as np +import Contour + +##!!!!!Faire le pretraitement + +#Test : Luminosite, orientation dans l'espace, distance +#Etudier les limites + +def FindCircles(): + image = None + while (image is None): + image = str(raw_input('\tImage to use ? By default couleur.png \n')) + if not image: + image = 'couleur.png' + image = cv2.imread(str(image), 0) + img = cv2.medianBlur(image, 5) + cimg = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR) + circles = cv2.HoughCircles(img, cv2.HOUGH_GRADIENT, 1, 20, param1 = 50, param2 = 30, minRadius = 0, maxRadius = 0) + circles = np.uint16(np.around(circles)) + for i in circles[0,:]: + cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),2) + cv2.circle(cimg,(i[0],i[1]),2,(0,0,255),3) + + cv2.imshow('detected circles',cimg) + cv2.waitKey(0) + cv2.destroyAllWindows() + return + +def FindShapes(): + image = None + while (image is None): + image = str(raw_input('\tImage to use ? By default couleur.png \n')) + if not image: + image = 'couleur.png' + image = cv2.imread(str(image)) + height, width, channels = image.shape + mask = np.zeros((height, width, 3), dtype = "uint8") + contours = Contour.FindContours(image) + img = image.copy() + #Contour.DrawContours(img, contours, "Contours Shape Detection") + for cnt in contours: + approx = cv2.approxPolyDP(cnt, 0.01*cv2.arcLength(cnt, True), True) + if len(approx) == 3 : + print "Triangle" + cv2.drawContours(image, [cnt], 0, (255, 255, 0), -1) + elif len(approx) == 4: + print "Square" + cv2.drawContours(image, [cnt], 0, (255, 255, 255), -1) + elif len(approx) == 5: + print "Pentagon" + cv2.drawContours(image, [cnt], 0, (0, 255, 0), -1) + #elif len(approx) == 8: + # print "Huit" + # cv2.drawContours(image, [cnt], 0, (0, 0, 0), -1) + elif len(approx) > 6 and len(approx) < 9: + print "Arrow" + cv2.drawContours(image, [cnt], 0, (255, 0, 255), -1) + cv2.drawContours(mask, [cnt], 0, (255,255,255), -1) + elif len(approx) > 19: + print "Circle" + cv2.drawContours(image, [cnt], 0, (255, 0, 0), -1) + cv2.imshow('Mask', mask) + cv2.imshow('detected shapes', image) + cv2.waitKey(0) + cv2.destroyAllWindows() + return diff --git a/Python/Application/Skeleton2.py b/Python/Application/Skeleton2.py new file mode 100644 index 0000000..748186f --- /dev/null +++ b/Python/Application/Skeleton2.py @@ -0,0 +1,63 @@ +import cv2 +import numpy as np + +def Skeletization(img, shape, size): + if shape == '1': + shape = cv2.MORPH_RECT + elif shape == '2': + shape = cv2.MORPH_ELLIPSE + elif shape == '3': + shape = cv2.MORPH_CROSS + else: + return + + cv2.normalize(img, img, 0, 255, cv2.NORM_MINMAX) + skeleton = np.zeros(img.shape, np.uint8) + eroded = np.zeros(img.shape, np.uint8) + temp = np.zeros(img.shape, np.uint8) + + _,thresh = cv2.threshold(img, 127, 255, 0) + + kernel = cv2.getStructuringElement(shape,(int(size), int(size))) + + while(True): + cv2.erode(thresh, kernel, eroded) + cv2.dilate(eroded, kernel, temp) + cv2.subtract(thresh, temp, temp) + cv2.bitwise_or(skeleton, temp, skeleton) + thresh, eroded = eroded, thresh + + if cv2.countNonZero(thresh) == 0: + break + + kernel = np.ones((20,20), np.uint8) + skeleton = cv2.morphologyEx(skeleton, cv2.MORPH_CLOSE, kernel) + cv2.imwrite('DefaultSkeleton.png', skeleton) + cv2.imshow('skeleton', skeleton) + return skeleton + +def KernelChoice(): + image = None + size = '0' + choice = '0' + print('\t\tSkeleton Menu\n') + while (image is None): + image = str(raw_input('\tImage to use? By default FondNoir.png \n')) + if not image: + image = 'FondNoir.png' + image = cv2.imread(str(image),0) + print('\t1. Rectangle\n\t2. Ellipse\n\t3. Cross\n') + while choice < '1' or choice > '3': + choice = raw_input('\n\tKernel Choice. Rectangle by Default\n') + if not choice: + choice = '1' + while int(size) % 2 == 0: + size = raw_input('\n\tPlease specify the kernel size (Odd number). By default it\'s 3\n') + if not size: + size = '3' + Skeletization(image, choice, size) + + cv2.waitKey(0) + cv2.destroyAllWindows() + + return diff --git a/Python/Application/Test.py b/Python/Application/Test.py new file mode 100644 index 0000000..73a8bcc --- /dev/null +++ b/Python/Application/Test.py @@ -0,0 +1,45 @@ +import cv2 +import numpy as np +import Contour +import ColorObject +from Parameters import * + +def ColoredArrow(): + image = cv2.imread('couleur.png') + height, width, channels = image.shape + mask = np.zeros((height, width, 3), dtype = "uint8") + contours = Contour.FindContours(image) + for cnt in contours: + tmp = cv2.contourArea(cnt) + approx = cv2.approxPolyDP(cnt, 0.01*cv2.arcLength(cnt, True), True) + if len(approx) > 6 and len(approx) < 9 and tmp > 1000: + print "Arrow" + cv2.drawContours(mask, [cnt], 0, (255,255,255), -1) + cv2.imshow('Mask', mask) + arrows = cv2.bitwise_and(image, mask) + cv2.imshow('Arrows', arrows) + cv2.imwrite('Arrows.png', arrows) + cv2.waitKey(0) + cv2.destroyAllWindows() + return arrows + +def FindColor(img): + height, width, channels = img.shape + blueMask, blueRes = ColorObject.IsolateObject(img, LowerBlue, UpperBlue) + redMask, redRes = ColorObject.IsolateObject(img, LowerRed, UpperRed) + greenMask, greenRes = ColorObject.IsolateObject(img, LowerGreen, UpperGreen) + greyRes = cv2.bitwise_xor(img, greenRes) + greyRes = cv2.bitwise_xor(greyRes, redRes) + greyRes = cv2.bitwise_xor(greyRes, blueRes) + kernel = np.ones((5,5),np.uint8) + greyRes = cv2.erode(greyRes,kernel,iterations = 1) + cv2.imshow('Grey Arrow', greyRes) + cv2.imshow('Red Arrow', redRes) + cv2.imshow('Blue Arrow', blueRes) + cv2.imshow('Green Arrow', greenRes) + cv2.waitKey(0) + cv2.destroyAllWindows() + return + +image = ColoredArrow() +FindColor(image) diff --git a/Python/Application/Threshold.py b/Python/Application/Threshold.py new file mode 100644 index 0000000..8911c01 --- /dev/null +++ b/Python/Application/Threshold.py @@ -0,0 +1,72 @@ +import cv2 +import numpy as np +from matplotlib import pyplot as plt + +def ThresholdEverything(img): + ret,th1 = cv2.threshold(img,127,255,cv2.THRESH_BINARY) + th2 = cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY,11,2) + th3 = cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,11,2) + titles = ['Original Image', 'Global Thresholding (v = 127)', + 'Adaptive Mean Thresholding', 'Adaptive Gaussian Thresholding'] + images = [img, th1, th2, th3] + for i in xrange(4): + plt.subplot(2,2,i+1),plt.imshow(images[i],'gray') + plt.title(titles[i]) + plt.xticks([]),plt.yticks([]) + plt.show() + return images + +def GlobalThresholding(img): + ret,th1 = cv2.threshold(img,127,255,cv2.THRESH_BINARY) + plt.plot(), plt.imshow(th1, 'gray') + plt.title('Global Thresholding (v = 127)') + plt.show() + return th1 + +def AdaptiveMeanThresholding(img): + th2 = cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY,11,2) + plt.plot(), plt.imshow(th2, 'gray') + plt.title('Adaptive Mean Thresholding') + plt.show() + return th2 + +def AdaptiveGaussianThresholding(img): + th3 = cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,11,2) + plt.plot(), plt.imshow(th3, 'gray') + plt.title('Adaptive Gaussian Thresholding') + plt.show() + return th3 + +def ThresholdChoiceProcessing(img, choice): + if choice == '1': + img = GlobalThresholding(img) + return img + elif choice == '2': + img = AdaptiveMeanThresholding(img) + return img + elif choice == '3': + img = AdaptiveGaussianThresholding(img) + return img + elif choice == '4': + img = ThresholdEverything(img) + return img + else: + return + + +def ThresholdChoice() : + image = None + print('\t\tThreshold Menu\n') + while (image is None): + image = str(raw_input('\tImage to use? By default couleur.png \n')) + if not image: + image = 'couleur.png' + image = cv2.imread(str(image), 0) + img = cv2.medianBlur(image,5) + print ('\t1. Global Thresholding\n\t2. Adaptive Mean Thresholding\n\t3. Adaptive Gaussian Thresholding\n\t4. Everything\n') + choice = raw_input('\n\tMultiple choices possible\n') + for i in range (0, len(choice)): + img = image.copy() + img = ThresholdChoiceProcessing(img, choice[i]) + return + diff --git a/Python/Application/couleur.png b/Python/Application/couleur.png new file mode 100644 index 0000000..eaf0d73 Binary files /dev/null and b/Python/Application/couleur.png differ diff --git a/Python/Application/main.py b/Python/Application/main.py new file mode 100644 index 0000000..9f152f2 --- /dev/null +++ b/Python/Application/main.py @@ -0,0 +1,49 @@ +import ColorObject +import Contour +import Gradient +import Skeleton2 +import Threshold +import ImageComponents +import ShapeDetection + +def ProcessChoiceMenu(choice): + if choice == '1': + ColorObject.ColorChoice() + elif choice == '2' : + Skeleton2.KernelChoice() + elif choice == '3' : + Contour.ContourChoice() + elif choice == '4' : + ImageComponents.Edges() + elif choice == '5' : + ImageComponents.Corners() + elif choice == '6' : + ShapeDetection.FindCircles() + elif choice == '7' : + ShapeDetection.FindShapes() + elif choice == '8' : + Gradient.GradientChoice() + elif choice == '9': + Threshold.ThresholdChoice() + else: + exit() + return + +def MenuApplication(): + print ('\t\t\tMenu Traitement d\'images \n\n') + print ('\t1. Find a colored object') + print ('\t2. Skeletisation') + print ('\t3. Contours') + print ('\t4. Canny edge detection') + print ('\t5. Corner detection') + print ('\t6. Find a circle') + print ('\t7. Find Basic shapes') + print ('\t8. Gradient') + print ('\t9. Threshold') + choice = raw_input('\n\tChoix multiple possible\n') + for i in range (0, len(choice)): + ProcessChoiceMenu(choice[i]) + return + +MenuApplication() + diff --git a/Python/B.png b/Python/B.png deleted file mode 100644 index dec34b9..0000000 Binary files a/Python/B.png and /dev/null differ diff --git a/Python/Blue.png b/Python/Blue.png deleted file mode 100644 index 77c2592..0000000 Binary files a/Python/Blue.png and /dev/null differ diff --git a/Python/BlueDrone.png b/Python/BlueDrone.png deleted file mode 100644 index 064eca7..0000000 Binary files a/Python/BlueDrone.png and /dev/null differ diff --git a/Python/CornersEdgesFleches.png b/Python/CornersEdgesFleches.png deleted file mode 100644 index c6c14ea..0000000 Binary files a/Python/CornersEdgesFleches.png and /dev/null differ diff --git a/Python/CornersFleches.png b/Python/CornersFleches.png deleted file mode 100644 index 14b9d1c..0000000 Binary files a/Python/CornersFleches.png and /dev/null differ diff --git a/Python/Debut/B.png b/Python/Debut/B.png new file mode 100644 index 0000000..dec34b9 Binary files /dev/null and b/Python/Debut/B.png differ diff --git a/Python/Debut/Blue.png b/Python/Debut/Blue.png new file mode 100644 index 0000000..77c2592 Binary files /dev/null and b/Python/Debut/Blue.png differ diff --git a/Python/Debut/BlueDrone.png b/Python/Debut/BlueDrone.png new file mode 100644 index 0000000..064eca7 Binary files /dev/null and b/Python/Debut/BlueDrone.png differ diff --git a/Python/Debut/CornersEdgesFleches.png b/Python/Debut/CornersEdgesFleches.png new file mode 100644 index 0000000..c6c14ea Binary files /dev/null and b/Python/Debut/CornersEdgesFleches.png differ diff --git a/Python/Debut/CornersFleches.png b/Python/Debut/CornersFleches.png new file mode 100644 index 0000000..14b9d1c Binary files /dev/null and b/Python/Debut/CornersFleches.png differ diff --git a/Python/Debut/G-RGB.png b/Python/Debut/G-RGB.png new file mode 100644 index 0000000..04fabe9 Binary files /dev/null and b/Python/Debut/G-RGB.png differ diff --git a/Python/Debut/Green.png b/Python/Debut/Green.png new file mode 100644 index 0000000..6d0829f Binary files /dev/null and b/Python/Debut/Green.png differ diff --git a/Python/Debut/GreenDrone.png b/Python/Debut/GreenDrone.png new file mode 100644 index 0000000..f934341 Binary files /dev/null and b/Python/Debut/GreenDrone.png differ diff --git a/Python/Debut/ImageComponents.py b/Python/Debut/ImageComponents.py new file mode 100644 index 0000000..b91cfac --- /dev/null +++ b/Python/Debut/ImageComponents.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python + +import cv2 +import numpy as np +import sys +from PIL import Image +from matplotlib import pyplot as plt + + +def Histogram(image): + color = ('b', 'g', 'r') + for i,col in enumerate(color): + histr = cv2.calcHist([image], [i], None, [256], [0,256]) + plt.plot(histr,color = col) + plt.xlim([0,256]) + plt.show() + +def Corners(image): + img = image.copy() + gray= cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) + gray = np.float32(gray) + dst = cv2.cornerHarris(gray, 5, 5, 0.15) + dst = cv2.dilate(dst, None) + img[dst>0.01*dst.max()] = [0,0,255] + cv2.imshow('dst', img) + return dst + +def Edges(image): + img = image.copy() + edges = cv2.Canny(img, 100, 200) + plt.subplot(121),plt.imshow(img,cmap='gray') + plt.title('Original Image'), plt.xticks([]), plt.yticks([]) + plt.subplot(122),plt.imshow(edges,cmap = 'gray') + plt.title('Edge Image'), plt.xticks([]), plt.yticks([]) + plt.show() + return edges + +def Components(image): + b = image.copy() + # set green and red channels to 0 + b[:, :, 1] = 0 + b[:, :, 2] = 0 + + g = image.copy() + # set blue and red channels to 0 + g[:, :, 0] = 0 + g[:, :, 2] = 0 + + r = image.copy() + # set blue and green channels to 0 + r[:, :, 0] = 0 + r[:, :, 1] = 0 + + return b,g,r + +#paper = image.copy() +#ret, thresh = cv2.threshold(cv2.cvtColor(paper, cv2.COLOR_BGR2GRAY), 100, 255, cv2.THRESH_BINARY) +#image2, contours, hier = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) +#for c in contours: +# rect = cv2.minAreaRect(c) +# box = cv2.boxPoints(rect) +# box = np.int0(box) +# cv2.drawContours(paper, [box], 0, (0, 255, 0),1) +#cv2.imshow('paper', paper) + +#image = cv2.imread('couleur.png') +image = cv2.imread('couleur.png') +#edges = Edges(image) +#cv2.imshow('image', image) +#Histogram(image) +dst = Corners(image) +#Histogram(image) +#r, g, b = Components(image) +#test = image[100, 200] +#print(test) +b,g,r = cv2.split(image) +#cv2.imwrite('RedDrone.png', r) +#cv2.imwrite('BlueDrone.png', b) +#cv2.imwrite('GreenDrone.png', g) + +cv2.waitKey(0) + + + +# RGB - Blue +#cv2.imshow('B-RGB',b, cmap = 'gray') +#cv2.imwrite("flecheBleue.png", b) + +# RGB - Green +#cv2.imshow('G-RGB', g) +#cv2.imwrite("flecheVerte.png", g) + +# RGB - Red +#cv2.imshow('R-RGB', r) +#cv2.imwrite("flecheRouge.png", r) + +#cv2.waitKey(0) diff --git a/Python/Debut/ImageDrone.png b/Python/Debut/ImageDrone.png new file mode 100644 index 0000000..e62ee70 Binary files /dev/null and b/Python/Debut/ImageDrone.png differ diff --git a/Python/Debut/R-RGB.png b/Python/Debut/R-RGB.png new file mode 100644 index 0000000..145bc51 Binary files /dev/null and b/Python/Debut/R-RGB.png differ diff --git a/Python/Debut/RGB_Bebop.png b/Python/Debut/RGB_Bebop.png new file mode 100644 index 0000000..f4d6073 Binary files /dev/null and b/Python/Debut/RGB_Bebop.png differ diff --git a/Python/Debut/Red.png b/Python/Debut/Red.png new file mode 100644 index 0000000..ee92eb6 Binary files /dev/null and b/Python/Debut/Red.png differ diff --git a/Python/Debut/RedDrone.png b/Python/Debut/RedDrone.png new file mode 100644 index 0000000..235e557 Binary files /dev/null and b/Python/Debut/RedDrone.png differ diff --git a/Python/Debut/Total.png b/Python/Debut/Total.png new file mode 100644 index 0000000..be805e5 Binary files /dev/null and b/Python/Debut/Total.png differ diff --git a/Python/Debut/TotalMedium.png b/Python/Debut/TotalMedium.png new file mode 100644 index 0000000..8b71da5 Binary files /dev/null and b/Python/Debut/TotalMedium.png differ diff --git a/Python/Debut/cornerDetectio,.png b/Python/Debut/cornerDetectio,.png new file mode 100644 index 0000000..0f55a6f Binary files /dev/null and b/Python/Debut/cornerDetectio,.png differ diff --git a/Python/Debut/couleur.png b/Python/Debut/couleur.png new file mode 100644 index 0000000..eaf0d73 Binary files /dev/null and b/Python/Debut/couleur.png differ diff --git a/Python/Debut/couleur2.png b/Python/Debut/couleur2.png new file mode 100644 index 0000000..21ee4e8 Binary files /dev/null and b/Python/Debut/couleur2.png differ diff --git a/Python/Debut/flecheBleue.png b/Python/Debut/flecheBleue.png new file mode 100644 index 0000000..bcd2bea Binary files /dev/null and b/Python/Debut/flecheBleue.png differ diff --git a/Python/Debut/flecheRouge.png b/Python/Debut/flecheRouge.png new file mode 100644 index 0000000..51c6294 Binary files /dev/null and b/Python/Debut/flecheRouge.png differ diff --git a/Python/Debut/flecheVerte.png b/Python/Debut/flecheVerte.png new file mode 100644 index 0000000..08c130f Binary files /dev/null and b/Python/Debut/flecheVerte.png differ diff --git a/Python/Debut/fleches.png b/Python/Debut/fleches.png new file mode 100644 index 0000000..8f26de8 Binary files /dev/null and b/Python/Debut/fleches.png differ diff --git a/Python/Debut/test.png b/Python/Debut/test.png new file mode 100644 index 0000000..e8b9746 Binary files /dev/null and b/Python/Debut/test.png differ diff --git a/Python/Debut/test.txt b/Python/Debut/test.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Python/Debut/test.txt diff --git a/Python/Documentation/ROScheatsheet.pdf b/Python/Documentation/ROScheatsheet.pdf new file mode 100644 index 0000000..3c7e4a2 Binary files /dev/null and b/Python/Documentation/ROScheatsheet.pdf differ diff --git a/Python/Documentation/opencv-python-tutroals.pdf b/Python/Documentation/opencv-python-tutroals.pdf new file mode 100644 index 0000000..2fed8d4 Binary files /dev/null and b/Python/Documentation/opencv-python-tutroals.pdf differ diff --git a/Python/Documentation/opencv_cheatsheet.pdf b/Python/Documentation/opencv_cheatsheet.pdf new file mode 100644 index 0000000..5fdfbba Binary files /dev/null and b/Python/Documentation/opencv_cheatsheet.pdf differ diff --git a/Python/Documentation/opencv_python_cheatsheet b/Python/Documentation/opencv_python_cheatsheet new file mode 100644 index 0000000..fe75d32 --- /dev/null +++ b/Python/Documentation/opencv_python_cheatsheet @@ -0,0 +1,89 @@ +
+
+ +

OpenCV

+ + + +

Filtre

+
+filter2D()          Filtre linéaire non séparable
+sepFilter2D()       Filtre linéaire séparable
+boxFilter(),        Lisse une image avec un filtre
+GaussianBlur(),     linéaire ou non linéaire
+medianBlur(),
+bilateralFilter().
+Sobel(),Scharr()    Calcule les dérivées de l'image spatiale
+Laplatian()         Calcule le Laplacien
+exode(),dilate()    Opérations morphologiques
+
+

Histogrammes

+
+calcHist()          Calcule l'histogramme d'une image
+calcBackProject()   Projette l'histogrmme
+equalizeHist()      Normalise le contraste et la luminosité 
+                    d'une image
+compareHist()       Compare deux histogrammes
+

Détection d'objets

+
+matchTemplate       Calcule la carte de distance pour un modèle 
+                    donné
+CascadeClassifier   
+HOGDescriptor       Détecteur d'objets de N. Dalal utilisant 
+                    l'histogramme des gradients orientés (HOG).
+
+

Manipulation de matrices

+
+src.copyTo(dst)     Copie une matrice vers une autre
+m.clone()           Fait une copie d'une matrice
+m.reshape(ch,rows)  Change les dimensions d'une matrice ou son 
+                    nombre de canaux sans copier les données
+m.row(i),m.col(i)   Prend la ligne/colonne d'une matrice
+m.rowRange(Range()) Prend un intervalle de lignes/colonnes
+m.colRange(Range())
+m.diag(i)           Prend la diagonale d'une matrice
+m(Range(),Range())  Prend une sous-matrice
+split()             Sépare les canaux d'une matrice 
+merge()             Fusionne plusieurs canaux dans une matrice
+
+ +

Transformations géométriques

+
+ resize()            Redimensionne l'image
+ getRectSubPix()     Extrait un patch
+ warpAffine()        Déforme une image affinement
+ warpPerspective()   Déforme une image perspectivement
+ remap()             Déformation d'image générique
+ convertMaps()       Optimise les chemins pour une exécution
+                     plus rapide de remap()
+

Diverses transformations d'image

+
+ cvtColor()          Convertit une image d'un espace 
+                     de couleur à l'autre
+ threshold()         Convertit une image niveau de gris en 
+                     image binaire
+ adaptivethreshold() Utilise un seuil fixe ou variable
+ floodFill()         Trouve un composant connecté en utilisant
+                     un algorithme de croissance de région
+ integral()          Calcule l'intégral d'une image
+ distanceTransform() Construit une carte de distance ou un
+                     diagramme discret de Voronir pour une 
+                     image binaire
+ watershed()         Algorithmes degmentation d'image à base
+ grabCut()           de marqueurs
+ +

Opérations arithmétiques

+
+ bitwise_and()       Opérations booléennes sur deux images    
+ bitwise_or()
+ bitwise_xor()
+ add()				 Additions de deux images 
+ addWeighted()       Mélange de deux images
+
+

Interface Graphique Simple

+
+ destroyWindow(name)  Détruit la fenêtre spécifiée
+ imshow(name, img)    Affiche une image dans une fenêtre
+ waitKey(delay)       Attend un appui de touche pendant le temps spécifié 
+ +
\ No newline at end of file diff --git a/Python/G-RGB.png b/Python/G-RGB.png deleted file mode 100644 index 04fabe9..0000000 Binary files a/Python/G-RGB.png and /dev/null differ diff --git a/Python/Green.png b/Python/Green.png deleted file mode 100644 index 6d0829f..0000000 Binary files a/Python/Green.png and /dev/null differ diff --git a/Python/GreenDrone.png b/Python/GreenDrone.png deleted file mode 100644 index f934341..0000000 Binary files a/Python/GreenDrone.png and /dev/null differ diff --git a/Python/ImageComponents.py b/Python/ImageComponents.py deleted file mode 100644 index b91cfac..0000000 --- a/Python/ImageComponents.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python - -import cv2 -import numpy as np -import sys -from PIL import Image -from matplotlib import pyplot as plt - - -def Histogram(image): - color = ('b', 'g', 'r') - for i,col in enumerate(color): - histr = cv2.calcHist([image], [i], None, [256], [0,256]) - plt.plot(histr,color = col) - plt.xlim([0,256]) - plt.show() - -def Corners(image): - img = image.copy() - gray= cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) - gray = np.float32(gray) - dst = cv2.cornerHarris(gray, 5, 5, 0.15) - dst = cv2.dilate(dst, None) - img[dst>0.01*dst.max()] = [0,0,255] - cv2.imshow('dst', img) - return dst - -def Edges(image): - img = image.copy() - edges = cv2.Canny(img, 100, 200) - plt.subplot(121),plt.imshow(img,cmap='gray') - plt.title('Original Image'), plt.xticks([]), plt.yticks([]) - plt.subplot(122),plt.imshow(edges,cmap = 'gray') - plt.title('Edge Image'), plt.xticks([]), plt.yticks([]) - plt.show() - return edges - -def Components(image): - b = image.copy() - # set green and red channels to 0 - b[:, :, 1] = 0 - b[:, :, 2] = 0 - - g = image.copy() - # set blue and red channels to 0 - g[:, :, 0] = 0 - g[:, :, 2] = 0 - - r = image.copy() - # set blue and green channels to 0 - r[:, :, 0] = 0 - r[:, :, 1] = 0 - - return b,g,r - -#paper = image.copy() -#ret, thresh = cv2.threshold(cv2.cvtColor(paper, cv2.COLOR_BGR2GRAY), 100, 255, cv2.THRESH_BINARY) -#image2, contours, hier = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) -#for c in contours: -# rect = cv2.minAreaRect(c) -# box = cv2.boxPoints(rect) -# box = np.int0(box) -# cv2.drawContours(paper, [box], 0, (0, 255, 0),1) -#cv2.imshow('paper', paper) - -#image = cv2.imread('couleur.png') -image = cv2.imread('couleur.png') -#edges = Edges(image) -#cv2.imshow('image', image) -#Histogram(image) -dst = Corners(image) -#Histogram(image) -#r, g, b = Components(image) -#test = image[100, 200] -#print(test) -b,g,r = cv2.split(image) -#cv2.imwrite('RedDrone.png', r) -#cv2.imwrite('BlueDrone.png', b) -#cv2.imwrite('GreenDrone.png', g) - -cv2.waitKey(0) - - - -# RGB - Blue -#cv2.imshow('B-RGB',b, cmap = 'gray') -#cv2.imwrite("flecheBleue.png", b) - -# RGB - Green -#cv2.imshow('G-RGB', g) -#cv2.imwrite("flecheVerte.png", g) - -# RGB - Red -#cv2.imshow('R-RGB', r) -#cv2.imwrite("flecheRouge.png", r) - -#cv2.waitKey(0) diff --git a/Python/ImageDrone.png b/Python/ImageDrone.png deleted file mode 100644 index e62ee70..0000000 Binary files a/Python/ImageDrone.png and /dev/null differ diff --git a/Python/PreProcessing/Filter.py b/Python/PreProcessing/Filter.py new file mode 100644 index 0000000..e019890 --- /dev/null +++ b/Python/PreProcessing/Filter.py @@ -0,0 +1,44 @@ +import cv2 +import numpy as np +from matplotlib import pyplot as plt + +image = cv2.imread('couleur.png') +bilateral = cv2.bilateralFilter(image, 5, 75, 75) +blur = cv2.blur(image, (5, 5)) +box = cv2.boxFilter(image, -1, (5, 5)) +DD = cv2.filter2D(image, -1, (5, 5)) +gaussian = cv2.GaussianBlur(image, (5, 5), 50) +median = cv2.medianBlur(image, 5) +sep = cv2.sepFilter2D(image, -1, 75, 75) + +kernel = np.array([[-1,-1,-1], [-1,9,-1], [-1,-1,-1]]) +im = cv2.filter2D(image, -1, kernel) +bilateral2 = cv2.bilateralFilter(im, 5, 150, 150) + +plt.subplot(2,3,1),plt.imshow(image) +plt.title('Original'), plt.xticks([]), plt.yticks([]) +plt.subplot(2,3,2),plt.imshow(bilateral) +plt.title('Bilateral Filter'), plt.xticks([]), plt.yticks([]) +plt.subplot(2,3,3),plt.imshow(blur) +plt.title('Blur'), plt.xticks([]), plt.yticks([]) +plt.subplot(2,3,4),plt.imshow(box) +plt.title('Box Filter'), plt.xticks([]), plt.yticks([]) +plt.subplot(2,3,5),plt.imshow(gaussian) +plt.title('Gaussian Filter'), plt.xticks([]), plt.yticks([]) +plt.subplot(2,3,6),plt.imshow(median) +plt.title('Median Blur'), plt.xticks([]), plt.yticks([]) +plt.show() + +cv2.imshow('Sharp', im) +cv2.imshow('Bilateral', bilateral2) +#cv2.imshow('original', image) +#cv2.imshow('bilateral filter', bilateral) +#cv2.imshow('blur', blur) +#cv2.imshow('box', box) +#cv2.imshow('filter 2D', DD) +#cv2.imshow('gaussian filter', gaussian) +#cv2.imshow('median blur', median) +#cv2.imshow('sep Filter 2D', sep) + +cv2.waitKey(0) +cv2.destroyAllWindows() diff --git a/Python/PreProcessing/couleur.png b/Python/PreProcessing/couleur.png new file mode 100644 index 0000000..eaf0d73 Binary files /dev/null and b/Python/PreProcessing/couleur.png differ diff --git a/Python/R-RGB.png b/Python/R-RGB.png deleted file mode 100644 index 145bc51..0000000 Binary files a/Python/R-RGB.png and /dev/null differ diff --git a/Python/RGB_Bebop.png b/Python/RGB_Bebop.png deleted file mode 100644 index f4d6073..0000000 Binary files a/Python/RGB_Bebop.png and /dev/null differ diff --git a/Python/Red.png b/Python/Red.png deleted file mode 100644 index ee92eb6..0000000 Binary files a/Python/Red.png and /dev/null differ diff --git a/Python/RedDrone.png b/Python/RedDrone.png deleted file mode 100644 index 235e557..0000000 Binary files a/Python/RedDrone.png and /dev/null differ diff --git a/Python/Total.png b/Python/Total.png deleted file mode 100644 index be805e5..0000000 Binary files a/Python/Total.png and /dev/null differ diff --git a/Python/TotalMedium.png b/Python/TotalMedium.png deleted file mode 100644 index 8b71da5..0000000 Binary files a/Python/TotalMedium.png and /dev/null differ diff --git a/Python/cornerDetectio,.png b/Python/cornerDetectio,.png deleted file mode 100644 index 0f55a6f..0000000 Binary files a/Python/cornerDetectio,.png and /dev/null differ diff --git a/Python/couleur.png b/Python/couleur.png deleted file mode 100644 index eaf0d73..0000000 Binary files a/Python/couleur.png and /dev/null differ diff --git a/Python/couleur2.png b/Python/couleur2.png deleted file mode 100644 index 21ee4e8..0000000 Binary files a/Python/couleur2.png and /dev/null differ diff --git a/Python/flecheBleue.png b/Python/flecheBleue.png deleted file mode 100644 index bcd2bea..0000000 Binary files a/Python/flecheBleue.png and /dev/null differ diff --git a/Python/flecheRouge.png b/Python/flecheRouge.png deleted file mode 100644 index 51c6294..0000000 Binary files a/Python/flecheRouge.png and /dev/null differ diff --git a/Python/flecheVerte.png b/Python/flecheVerte.png deleted file mode 100644 index 08c130f..0000000 Binary files a/Python/flecheVerte.png and /dev/null differ diff --git a/Python/fleches.png b/Python/fleches.png deleted file mode 100644 index 8f26de8..0000000 Binary files a/Python/fleches.png and /dev/null differ diff --git a/Python/test.png b/Python/test.png deleted file mode 100644 index e8b9746..0000000 Binary files a/Python/test.png and /dev/null differ diff --git a/Python/test.txt b/Python/test.txt deleted file mode 100644 index e69de29..0000000 --- a/Python/test.txt +++ /dev/null -- libgit2 0.21.2