From Harmless Tapir, 5 Months ago, written in Plain Text.
Embed
Hits: 157
1. import numpy as np
2. from skimage import io, transform, morphology
3. from skimage.color import rgb2gray
4. from skimage.filters import sobel
5. import scipy.misc
6.
7. #wczytanie zdjec
8. photo=[]
9. photo.append('planes/samolot08.jpg')
10. photo.append('planes/samolot09.jpg')
11. photo.append('planes/samolot10.jpg')
12. photo.append('planes/samolot11.jpg')
13. photo.append('planes/samolot12.jpg')
14. photo.append('planes/samolot14.jpg')
15. #for i, value in enumerate (photo):
16.     #print(value)
17.
18.
19. #zapis zdjecia w tablicy
20. photoarray=[]
21. for value in photo:
23. #print(photoarray[0])
24.
25.
26. #zmiana tablicy na 2d
27. array2d=[]
28. for value2 in photoarray:
29.     array2d.append(rgb2gray(value2))
30. #print(array2d[0])
31.
32.
33. #robienie obrysu samolotow
34. contour=[]
35. for k, value3 in enumerate (array2d):
36.     contour.append(sobel(value3))
37.
38.
39.
40. #zmiana rozmiaru dowolnego zdjÄ™cia na taki sam jak inne
41. photoend=[]
42. for l, value4 in enumerate (contour):
43.     photoend.append(scipy.misc.imresize(value4,(264,400)))
44.
45. line1 = np.concatenate((photoend[0],photoend[1],photoend[2]),axis=1)
46. line2 = np.concatenate((photoend[3],photoend[4],photoend[5]),axis=1)
47. image = np.concatenate((line1,line2),axis=0)
48.
49. #image2 = morphology.dilation(image,np.square(3))
50.
51. scipy.misc.imsave('image.jpg',image)
52. #scipy.misc.imsave('image2.jpg',image2)