#!/usr/bin/env python3 # -*- coding: UTF-8 -*- import os, sys import time import datetime import io import urllib3 import httplib2 from PIL import Image, ImageFilter, ImageMath import numpy as np # ########################################################### # Main if __name__=="__main__": img=Image.open("2016_02_20_18_48_51-4.jpg") arrsh=np.hsplit(imga, 4) m=list() for x in range(len(arrsh)): i2=Image.fromarray(arrsh[x]) m.append(np.sum(i2)) i2.save("x%d.jpg"%(x)) print(m) mmi=m.index(max(m)) print(mmi) m=list() arrsv=np.vsplit(arrsh[mmi], 4) for y in range(len(arrsv)): i2=Image.fromarray(arrsv[y]) m.append(np.sum(i2)) i2.save("x%dy%d.jpg"%(mmi, y)) print(m) mmj=m.index(max(m)) print(mmj) |
![]() |
![]() |
![]() |
![]() |
1.968.049 | 105.019 | 107.097 | 87.470 |
![]() |
3.305 |
![]() |
41.311 |
![]() |
1.100.342 |
![]() |
823.091 |
#!/usr/bin/env python3 # -*- coding: UTF-8 -*- import os, sys import time import datetime import io import urllib3 import httplib2 from PIL import Image, ImageFilter, ImageMath import numpy as np # ########################################################### # Liefert von dem Grauwert-Bild "img" die Koordinaten des # hellsten Bereiches. # Das Bild wird dazu in 16 Bereiche gekachelt. # Die Koordinaten (0, 0) liegen links oben im Bild. def findBrightestArea(img): arr=np.asarray(img) arrsh=np.hsplit(arr, 4) # horizontal in 4 Blöcke zerlegen m=list() for x in range(len(arrsh)): # über alle 4 Blöcke m.append(np.sum(arrsh[x])) # Summe des Blocks merken mh=m.index(max(m)) # Index des Blocks mit der größten Summe m=list() arrsv=np.vsplit(arrsh[mh], 4) # hellsten Block vertikal in 4 Blöcke zerlegen for y in range(len(arrsv)): m.append(np.sum(arrsv[y])) mv=m.index(max(m)) return(mh, mv) # ########################################################### # Main if __name__=="__main__": img=Image.open("2016_02_20_18_48_51-4.jpg") t1=time.clock() a=findBrightestArea(img) t2=time.clock() print(a) print((t2-t1)*1000, "ms") |
dede@i5:~/bastelein/ipcam> ./tst5.py
(0, 2)
1.5020000000000033 ms