repl.it
@manumanuk/

Analyzing Image

Python

No description

fork
loading
Files
  • main.py
  • image.jpg
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'''import cv2
import numpy as np
img = cv2.imread('image.jpg')
px=img[100, 100]
print(px)'''
import imageio
import matplotlib.pyplot as plt
import time
# import pygame
# pygame.init()
# pygame.mixer.init()
pic = imageio.imread('image.jpg')
plt.figure(figsize = (15,15))
plt.imshow(pic)

imageHeight=pic.shape[0]
imageWidth=pic.shape[1]
imagePixels=[]
print(pic.shape)
startTime=time.time()
#for pixelNumber in range (0, imageWidth*imageHeight,500):
xVal=0
increment=15
for yVal in range (0, imageHeight,15):
  while True:
    if xVal>imageWidth:
      increment= (-increment)
      xVal+=increment
      break
    elif xVal<0:
      increment= (-increment)
      xVal+=increment
      break
    else:  
      imagePixels.append(pic[yVal, xVal])
      xVal+=increment
    print('pixel ' + str(xVal) + ', ' + str(yVal))
elapsedTime=time.time()-startTime



print('done in ' + str(elapsedTime))
Fetching token
?