Skip to content

Instantly share code, notes, and snippets.

@flxw
Created June 4, 2017 19:20
Show Gist options
  • Save flxw/1a6e2b90977713f5fc8f4c1d145da531 to your computer and use it in GitHub Desktop.
Save flxw/1a6e2b90977713f5fc8f4c1d145da531 to your computer and use it in GitHub Desktop.
from PIL import Image
import multiprocessing
def test_screen(pic): #Prozess
file_prefix = 'MA_HA1_drawing_'
file_postfix = '.png'
file_name = file_prefix + str(pic) + file_postfix
im = Image.open(file_name)
pix = im.load()
ws_o = 756
ws_u = 3712
ws_l = 616
ws_r = 6446
defect_pix = 0
for y in range(ws_o,ws_u,1):
for x in range (ws_l,ws_r,1):
if (pix[x,y][0] !=1 or pix[x,y][1] !=1 or pix[x,y][2] !=1):
defect_pix = defect_pix +1
#print 'Bei', x, y, '/', 'R:', pix[x,y][0], 'G:', pix[x,y][1], 'B', pix[x,y][2]
return (pic,defect_pix)
nImages = 3
process_pool = multiprocessing.Pool(processes = nImages)
defect_pixels = process_pool.map(test_screen, range(nImages))
#for pic in range (nImages):
# test_screen(pic)
# procs.append(Process(target=test_screen, args=(pic,)))
# procs.start()
#
#for p in procs:
# p.join()
for pair in defect_pixels:
print 'Anzahl der defekten Pixel bei Bildschirm #', pair[0], ': ', pair[1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment