Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Classification of Text-Background Color Combination
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
s183927
Classification of Text-Background Color Combination
Commits
3f043504
Commit
3f043504
authored
Jan 9, 2019
by
s183897
Browse files
Options
Downloads
Patches
Plain Diff
Added a few comments
parent
2134b5c5
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
main (K-means).py
+6
-0
6 additions, 0 deletions
main (K-means).py
main (nearest neighbor).py
+5
-0
5 additions, 0 deletions
main (nearest neighbor).py
with
11 additions
and
0 deletions
main (K-means).py
+
6
−
0
View file @
3f043504
# -*- coding: utf-8 -*-
# K-means Text Color Chooser: Main
import
pygame
import
os
import
numpy
as
np
...
...
@@ -46,7 +48,9 @@ points = np.reshape(np.array([randint(0,255), randint(0,255), randint(0,255)]),
white
=
np
.
reshape
(
np
.
array
([
randint
(
0
,
255
),
randint
(
0
,
255
),
randint
(
0
,
255
)]),
(
-
1
,
3
))
black
=
np
.
reshape
(
np
.
array
([
randint
(
0
,
255
),
randint
(
0
,
255
),
randint
(
0
,
255
)]),
(
-
1
,
3
))
# ////////////////////////////////////////////////////////////
# write on screen
# ////////////////////////////////////////////////////////////
def
text
(
msg
,
color
,
font
,
x
,
y
):
screen_text
=
font
.
render
(
msg
,
True
,
color
)
display
.
blit
(
screen_text
,
[
x
,
y
])
...
...
@@ -157,8 +161,10 @@ while True:
for
n
in
range
(
1
,
len
(
black
)):
ax
.
scatter
(
black
[
n
,
0
],
black
[
n
,
1
],
black
[
n
,
2
],
color
=
"
black
"
)
ax
.
scatter
(
color
[
0
],
color
[
1
],
color
[
2
],
color
=
"
blue
"
)
# display clusters
ax
.
scatter
(
whitecluster
[:,
0
],
whitecluster
[:,
1
],
whitecluster
[:,
2
],
marker
=
'
*
'
,
c
=
'
white
'
,
s
=
500
)
ax
.
scatter
(
blackcluster
[:,
0
],
blackcluster
[:,
1
],
blackcluster
[:,
2
],
marker
=
'
*
'
,
c
=
'
black
'
,
s
=
500
)
# axis labels
ax
.
set_xlabel
(
'
R
'
,
fontsize
=
15
)
ax
.
set_ylabel
(
'
G
'
,
fontsize
=
15
)
ax
.
set_zlabel
(
'
B
'
,
fontsize
=
15
)
...
...
This diff is collapsed.
Click to expand it.
main (nearest neighbor).py
+
5
−
0
View file @
3f043504
# -*- coding: utf-8 -*-
# Nearest Neighbor Text Color Chooser: Main
import
pygame
import
os
import
time
...
...
@@ -46,7 +48,9 @@ points = np.array([[1000000,1000000,1000000]])
white
=
np
.
array
([[
1000000
,
1000000
,
1000000
]])
black
=
np
.
array
([[
1000000
,
1000000
,
1000000
]])
# ////////////////////////////////////////////////////////////
# write on screen
# ////////////////////////////////////////////////////////////
def
text
(
msg
,
color
,
font
,
x
,
y
):
screen_text
=
font
.
render
(
msg
,
True
,
color
)
display
.
blit
(
screen_text
,
[
x
,
y
])
...
...
@@ -155,6 +159,7 @@ while True:
for
n
in
range
(
1
,
len
(
black
)):
ax
.
scatter
(
black
[
n
,
0
],
black
[
n
,
1
],
black
[
n
,
2
],
color
=
"
black
"
)
ax
.
scatter
(
color
[
0
],
color
[
1
],
color
[
2
],
color
=
"
blue
"
)
# axis labels
ax
.
set_xlabel
(
'
R
'
,
fontsize
=
15
)
ax
.
set_ylabel
(
'
G
'
,
fontsize
=
15
)
ax
.
set_zlabel
(
'
B
'
,
fontsize
=
15
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment