Advertisement
GabrielePozzoli

luminositaPixelRighe

Nov 10th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1.  
  2. def numRow(pict):
  3. #@param pict: Picture
  4. #@param count: int; numero righe con pixel aventi la stessa luminisota
  5.   count=0
  6.   for y in range(0,getHeight(pict)):
  7.     if numPix(pict,y):
  8.       count=count+1
  9.   return count
  10.  
  11. def numPix(source,h):
  12. #@param source: Picture
  13. #@param h: int; coordinata y dell immagine
  14. #@return bool
  15.   count=0
  16.   pix1=getPixel(source,0,0)
  17.   for x in range(0,getWidth(source)):
  18.     pix2=getPixel(source,x,h)
  19.     if lum(pix1)==lum(pix2):
  20.       count=count+1
  21.   if count==getWidth(source):
  22.     return true
  23.   else:
  24.     return false
  25.  
  26. def lum(px):
  27. #@param px: Pixel
  28. #@return int; luminosita del pixel
  29.   r=getRed(px)
  30.   g=getGreen(px)
  31.   b=getBlue(px)
  32.   lumi=r+g+b
  33.   return (lumi)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement