Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def lineDetect(orig, threshold):
- # @param orig: pict; immagine di partenza
- # @param threshold: int (for most pictures, good results for values <50)
- # @return pict
- makeBw = duplicatePicture(orig)
- for x in range(0,getWidth(orig)-1):
- for y in range(0, getHeight(orig) -1):
- here=getPixel(makeBw,x,y)
- down=getPixel(orig,x,y+1)
- right=getPixel(orig, x+1,y)
- hereLum=(getRed(here)+getGreen(here)+getBlue(here))/3
- downLum=(getRed(down)+getGreen(down)+getBlue(down))/3
- rightLum=(getRed(right)+getGreen(right)+getBlue(right))/3
- if abs(hereLum-downLum)>threshold and abs(hereLum-rightLum)>threshold:
- setColor(here ,black)
- if abs(hereLum-downLum)<=threshold or abs(hereLum-rightLum)<=threshold:
- setColor(here ,white)
- return makeBw
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement