-
Notifications
You must be signed in to change notification settings - Fork 12
/
flag patter in python
35 lines (28 loc) · 1.27 KB
/
flag patter in python
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
import skimage
import os
from skimage import io
# Reading image file
image2 = io.imread(' .jpg') #path of flag in the system #path.jpg
# Setting dimensions boundaries
x = 189 / 2
y = 267 / 2
r = 189 / 6
# Iterating to all the pixels in the set boundaries
for i in range(0, 189):
for j in range(0, 267):
if i in range(0, 189 / 3):
image2[i][j] = [255, 128, 64] # Orange Color
elif i in range(189 / 3, 189 * 2 / 3):
image2[i][j] = [255, 255, 255] # White Color
else:
image2[i][j] = [0, 128, 0] # Green Color
# Equation for 2px thick ring
if (( pow((x-i), 2) + pow((y-j), 2) ) <= pow(r + 1, 2)) and(( pow((x-i), 2) + pow((y-j), 2) ) >= pow(r-2, 2)):
image2[i][j] = [0, 0, 255] # Blue Color
# Iterating within the ring
for i in range(189 / 3, 189 * 2 / 3):
for j in range(267 / 3, 267 * 2 / 3):
# Equation to draw 4 straight lines
if ((i == 189 / 2) or (j == 267 / 2) or (i + 39 == j or (i + 39 + j == 266))) and (( pow((x-i), 2) + pow((y-j), 2) ) <= pow(r, 2)) :
image2[i][j] = [0, 0, 255] # Blue Color
io.imshow(image2) #output of the flag (indian flag)