Skip to content
This repository has been archived by the owner on Jan 17, 2019. It is now read-only.

Commit

Permalink
conflit resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
LeC-D committed Nov 23, 2018
2 parents 9766013 + 490d437 commit c802ac8
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions Projet/Clipping/Clipping.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,48 @@
import numpy as np

WHITE_PIXEL = 255
BLACK_PIXEL = 0


class Clipping:

def clip(self, edgesImage):
self.image = edgesImage
self.image = np.asarray(edgesImage)
y1 = self.calculY1()
y2 = self.calculY2()
print('y1', y1, 'y2', y2)
clipping_level = max(y1, y2)
for i in range(clipping_level, len(self.image)):
zeros = np.zeros(len(self.image[i]))
zeros = np.zeros(len(self.image[i])).astype('uint8')
self.image[i] = zeros
return self.image

def calculY1(self):
y1 = len(self.image)
y1 = len(self.image) - 1
for i in range(len(self.image) - 1, 0, -1):
for j in range(0, len(self.image[i])):
if j < len(self.image[i]) - 3:
if self.image[i][j] == WHITE_PIXEL and self.image[i][j+1] == WHITE_PIXEL and self.image[i][j+1] == WHITE_PIXEL:
# print('ligne', i, 'pixel 1', self.image[i][j], 'pixel 2', self.image[i][j+1], 'pixel 3', self.image[i][j+2])
if self.image[i][j] != BLACK_PIXEL and self.image[i][j+1] != BLACK_PIXEL and self.image[i][j+2] != BLACK_PIXEL:
y1 = i
return y1
return y1

def calculY2(self):
y2 = len(self.image)
y2 = len(self.image) - 1
diff = -1
for i in range(len(self.image) - 1, 0, -1):
first_white_pixel = -1
last_white_pixel = len(self.image[i])
for j in range(0,len(self.image[i])):
if first_white_pixel != -1 and self.image[i][j] == WHITE_PIXEL:
for j in range(0, len(self.image[i])):
if first_white_pixel != -1 and self.image[i][j] != BLACK_PIXEL:
first_white_pixel = j
elif self.image[i][j] == WHITE_PIXEL:
elif self.image[i][j] != BLACK_PIXEL:
last_white_pixel = j
newdiff = last_white_pixel - first_white_pixel
if diff == -1:
diff = newdiff
elif abs(diff - newdiff) > 10:
elif abs(diff - newdiff) > 35:
y2 = i
return y2
return y2
return y2

0 comments on commit c802ac8

Please sign in to comment.