Skip to content

Commit

Permalink
in process 151216
Browse files Browse the repository at this point in the history
  • Loading branch information
comsomisha committed Dec 15, 2016
1 parent 5d823e1 commit e96f56c
Show file tree
Hide file tree
Showing 55 changed files with 364 additions and 4 deletions.
Binary file modified Python1/Python1.v11.suo
Binary file not shown.
65 changes: 62 additions & 3 deletions Python1/Python1/Python1.pyproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,70 @@
<DebugSymbols>true</DebugSymbols>
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
</PropertyGroup>
<ItemGroup>
<Folder Include="examples\" />
<Folder Include="numbers\" />
<Folder Include="numbers\0\" />
<Folder Include="numbers\1\" />
<Folder Include="numbers\2\" />
<Folder Include="numbers\3\" />
<Folder Include="numbers\4\" />
<Folder Include="numbers\5\" />
<Folder Include="numbers\6\" />
<Folder Include="numbers\7\" />
<Folder Include="numbers\8\" />
<Folder Include="numbers\9\" />
</ItemGroup>
<ItemGroup>
<Content Include="examples\03612.gif" />
<Content Include="examples\08740.gif" />
<Content Include="examples\09651.gif" />
<Content Include="examples\18840.gif" />
<Content Include="examples\30380.gif" />
<Content Include="examples\51683.gif" />
<Content Include="examples\53361.gif" />
<Content Include="examples\55322.gif" />
<Content Include="examples\55824.gif" />
<Content Include="examples\62030.gif" />
<Content Include="examples\64039.gif" />
<Content Include="examples\67615.gif" />
<Content Include="examples\72581.gif" />
<Content Include="examples\76742.gif" />
<Content Include="examples\83913.gif" />
<Content Include="examples\90011.gif" />
<Content Include="numbers\0\5e11e68560ee3934a166ab8c3d839ec0.gif" />
<Content Include="numbers\0\a8485ec4708538e947eb35559d1f805b.gif" />
<Content Include="numbers\1\92461aaaf959ce074f38c67335fa3ac2.gif" />
<Content Include="numbers\1\9d7d6c9635a689b9ef7efa68239ebbbd.gif" />
<Content Include="numbers\1\a8201034c6c11dedadd47ac36098ac92.gif" />
<Content Include="numbers\2\15e9c21959ab260642d646514376b9e4.gif" />
<Content Include="numbers\2\2e3642357258f2ed2e13938df14c2bd6.gif" />
<Content Include="numbers\2\6840aadd5ad7399dc65f865cf37f76da.gif" />
<Content Include="numbers\3\243a0a35f68acc15b52f0467ce3fb6f8.gif" />
<Content Include="numbers\3\b1e3d5c2978d7cb8da1f6b9f3807766e.gif" />
<Content Include="numbers\3\fdb5d5b2a26d372a44052c0db900193f.gif" />
<Content Include="numbers\4\3a646d12eeb30b45afa60090c5b477fd.gif" />
<Content Include="numbers\4\6b0232684f8899e4f1c89a329b8b9644.gif" />
<Content Include="numbers\4\adba6edb36f7938b943e7fcc0ca15c3e.gif" />
<Content Include="numbers\5\35009d1f2a28ab720991419dccac6bd4.gif" />
<Content Include="numbers\5\ca47d52928a6f677652a0040b723d4e5.gif" />
<Content Include="numbers\5\d335cf3f7b1ddbda3108853fdbf6abf1.gif" />
<Content Include="numbers\6\ce8a456155f16f72913302554484312e.gif" />
<Content Include="numbers\6\e42c7854f99ce9a3a2b283167fc55413.gif" />
<Content Include="numbers\6\eef0185026fcd17f03b13f5747a74399.gif" />
<Content Include="numbers\7\7018355c856aeeb1574fc9fb4aa1d6d9.gif" />
<Content Include="numbers\7\944f5237fa9f20b31cac49f8758d4485.gif" />
<Content Include="numbers\7\bc549ed8972a5f34f7ff69c575093583.gif" />
<Content Include="numbers\8\83023956997f3259f8bcd7fdf572e47a.gif" />
<Content Include="numbers\8\8b8c62071cbe6878d07f292fe1264be9.gif" />
<Content Include="numbers\8\c47d86f5d5ebba9ce17041be2d7a9366.gif" />
<Content Include="numbers\9\78600b86803e1e185d2143b7e119942b.gif" />
<Content Include="numbers\9\bf3f011da7252edad4d2183f334bbfb2.gif" />
<Content Include="numbers\9\cba5dddd2bd5c682ebbd0eeea5c177ff.gif" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form.py" />
<Compile Include="Module.py">
<SubType>Code</SubType>
</Compile>
<Compile Include="Module.py" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
Expand Down
6 changes: 6 additions & 0 deletions Python1/Python1/Python1.pyproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ProjectFiles</ProjectView>
</PropertyGroup>
</Project>
Binary file added Python1/Python1/examples/03612.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Python1/Python1/examples/08740.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Python1/Python1/examples/09651.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Python1/Python1/examples/18840.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Python1/Python1/examples/30380.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Python1/Python1/examples/51683.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Python1/Python1/examples/53361.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Python1/Python1/examples/55322.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Python1/Python1/examples/55824.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Python1/Python1/examples/62030.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Python1/Python1/examples/64039.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Python1/Python1/examples/67615.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Python1/Python1/examples/72581.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Python1/Python1/examples/76742.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Python1/Python1/examples/83913.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Python1/Python1/examples/90011.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
132 changes: 132 additions & 0 deletions Python1/Python1/finish.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
from PIL import Image
import hashlib
import time
import os, sys


import math

class VectorCompare:
def magnitude(self,concordance):
total = 0
for word,count in concordance.items():
total += count ** 2
return math.sqrt(total)

def relation(self,concordance1, concordance2):
relevance = 0
topvalue = 0
for word, count in concordance1.items():
if word in concordance2:
topvalue += count * concordance2[word]
return topvalue / (self.magnitude(concordance1) * self.magnitude(concordance2))



def buildvector(im):
d1 = {}

count = 0
for i in im.getdata():
d1[count] = i
count += 1

return d1

v = VectorCompare()


iconset = ['0','1','2','3','4','5','6','7','8','9']


imageset = []

for letter in iconset:
for img in os.listdir('./numbers/%s/'%(letter)):
temp = []
if img != "Thumbs.db" and img != ".DS_Store":
temp.append(buildvector(Image.open("./numbers/%s/%s"%(letter,img))))
imageset.append({letter:temp})

correctcount = 0
wrongcount = 0


for filename in os.listdir('./examples/'):
try:
im = Image.open("./examples/%s"%(filename))
newim = Image.new("RGB",im.size)
newim.paste(im)
except:
break

print("")
print(filename)

im2 = Image.new("P",im.size)
im = newim.convert("P")
temp = {}

for x in range(im.size[1]):
for y in range(im.size[0]):
pix = im.getpixel((y,x))
temp[pix] = pix
if pix == 220 or pix==225 or pix == 227:
im2.putpixel((y,x),255)

inletter = False
foundletter=False
start = 0
end = 0

letters = []

for y in range(im2.size[0]):
for x in range(im2.size[1]):
pix = im2.getpixel((y,x))
if pix != 255:
inletter = True

if foundletter == False and inletter == True:
foundletter = True
start = y

if foundletter == True and inletter == False:
foundletter = False
end = y
letters.append((start,end))


inletter=False

count = 0
guessword = ""
for letter in letters:
m = hashlib.md5()
im3 = im2.crop(( letter[0] , 0, letter[1],im2.size[1] ))

guess = []

for image in imageset:
for x,y in image.items():
if len(y) != 0:
guess.append( ( v.relation(y[0],buildvector(im3)),x) )

guess.sort(reverse=True)
print("",guess[0])
guessword = "%s%s"%(guessword,guess[0][1])

count += 1
if guessword == filename[:-4]:
correctcount += 1
else:
wrongcount += 1


print("=======================")
correctcount = float(correctcount)
wrongcount = float(wrongcount)
print("Correct Guesses - ",correctcount)
print("Wrong Guesses - ",wrongcount)
print("Percentage Correct - ", correctcount/(correctcount+wrongcount)*100.00)
print("Percentage Wrong - ", wrongcount/(correctcount+wrongcount)*100.00)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Python1/Python1/output.gif
Binary file added Python1/Python1/proba.gif
107 changes: 107 additions & 0 deletions Python1/Python1/proba.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
from PIL import Image
import hashlib
import time
import os


import math

class VectorCompare:
def magnitude(self,concordance):
total = 0
for word,count in concordance.items():
total += count ** 2
return math.sqrt(total)

def relation(self,concordance1, concordance2):
relevance = 0
topvalue = 0
for word, count in concordance1.items():
if word in concordance2:
topvalue += count * concordance2[word]
return topvalue / (self.magnitude(concordance1) * self.magnitude(concordance2))



def buildvector(im):
d1 = {}

count = 0
for i in im.getdata():
d1[count] = i
count += 1

return d1

v = VectorCompare()


iconset = ['0','1','2','3','4','5','6','7','8','9']


imageset = []

for letter in iconset:
for img in os.listdir('./numbers/%s/'%(letter)):
temp = []
if img != "Thumbs.db" and img != ".DS_Store":
temp.append(buildvector(Image.open("./numbers/%s/%s"%(letter,img))))
imageset.append({letter:temp})


im = Image.open("proba.gif")
newim = Image.new("RGB",im.size)
newim.paste(im)
im2 = Image.new("P",im.size)
im = newim.convert("P")
temp = {}

for x in range(im.size[1]):
for y in range(im.size[0]):
pix = im.getpixel((y,x))
temp[pix] = pix
if pix == 220 or pix==225 or pix == 227:
im2.putpixel((y,x),255)

inletter = False
foundletter=False
start = 0
end = 0

letters = []
print("\n")
for y in range(im2.size[0]):
for x in range(im2.size[1]):
pix = im2.getpixel((y,x))
if pix != 255:
inletter = True

if foundletter == False and inletter == True:
foundletter = True
start = y

if foundletter == True and inletter == False:
foundletter = False
end = y
letters.append((start,end))


inletter=False

count = 0
for letter in letters:
m = hashlib.md5()
im3 = im2.crop(( letter[0] , 0, letter[1],im2.size[1] ))

guess = []

for image in imageset:
for x,y in image.items():
if len(y) != 0:
guess.append( ( v.relation(y[0],buildvector(im3)),x) )

guess.sort(reverse=True)
print("",guess[0])

count += 1
print("\nEXPECTED - 0022756")
55 changes: 55 additions & 0 deletions Python1/Python1/start.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from PIL import Image
import hashlib
import time

im = Image.open("examples/12581.gif")
newim = Image.new("RGB",im.size)
newim.paste(im)
im2 = Image.new("P",im.size)
im = newim.convert("P")

temp = {}


for x in range(im.size[1]):
for y in range(im.size[0]):
pix = im.getpixel((y,x))
temp[pix] = pix
if pix == 220 or pix == 225 or pix == 227:
im2.putpixel((y,x),255)

im2.save("output.gif")

inletter = False
foundletter=False
start = 0
end = 0

letters = []


for y in range(im2.size[0]):
for x in range(im2.size[1]):
pix = im2.getpixel((y,x))
if pix != 255:
inletter = True

if foundletter == False and inletter == True:
foundletter = True
start = y

if foundletter == True and inletter == False:
foundletter = False
end = y
letters.append((start,end))

inletter=False

count = 0
for letter in letters:
m = hashlib.md5()
im3 = im2.crop(( letter[0] , 0, letter[1],im2.size[1] ))
line = "%s%s"%(time.time(),count)
m.update(line.encode('utf-8'))
im3.save("numbers/%s.gif"%(m.hexdigest()))
count += 1
3 changes: 2 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
������������� ����� �� ������������.
��������� - �� ����� Python.
����� ������������ ���������� pillow.
����� Examples - ��� ��������.
����� numbers - ��� ��������.
����� examples - ������������� �����.

0 comments on commit e96f56c

Please sign in to comment.