Skip to content

Commit

Permalink
create filter function in beadfinder class to filter pictures
Browse files Browse the repository at this point in the history
  • Loading branch information
saadati944 committed Jan 12, 2021
1 parent cdc4b18 commit 4d6faed
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion beadfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Blob:
'''
The blob object contains the coordinates of connected pixels.
'''

def __init__(self):
'''
create new instance of blob object
Expand Down Expand Up @@ -53,7 +54,32 @@ def __str__(self):

class BeadFinder:
def __init__(self, pic, tau):
pass
'''
create new instance of beadfinder object
and initialization self.pic and self.tau
'''
self.tau = tau
self.pic = picture.Picture(pic)

def __getavg(self, clr):
'''
calculate average of R, G, B values of a color
like converting colors to gray scale
'''
return (clr.getRed()+clr.getGreen()+clr.getBlue())/3

def filter(self):
'''
filter pic according to threshold
colors under tau => black
colors above tau => white
'''
for i in range(self.pic.width()):
for j in range(self.pic.height()):
if self.__getavg(self.pic.get(i, j)) < self.tau:
self.pic.set(i, j, color.Color(0, 0, 0))
else:
self.pic.set(i, j, color.Color(255, 255, 255))

def getBeads(self, min_pixels):
pass
Expand Down

0 comments on commit 4d6faed

Please sign in to comment.