Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
I
image_analyzer
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
John
image_analyzer
Commits
b1616c40
Commit
b1616c40
authored
Aug 23, 2018
by
John
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated visualizer, and made parameterized some more
parent
c363831d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
29 deletions
+64
-29
checkit.html
checkit.html
+56
-21
colors.json
colors.json
+4
-6
img2.jpg
img2.jpg
+0
-0
smalltest.jpg
smalltest.jpg
+0
-0
main.rs
src/main.rs
+4
-2
No files found.
checkit.html
View file @
b1616c40
...
@@ -17,29 +17,64 @@
...
@@ -17,29 +17,64 @@
<script>
<script>
var
colors
=
[]
var
colors
=
[]
$
.
getJSON
(
"./colors.json"
,
function
(
data
){
console
.
log
(
data
);
function
palette
(){
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
log
(
"palette"
);
colors
.
push
(
data
[
i
]);
var
$myCanvas
=
$
(
'#myCanvas'
);
}
for
(
var
i
=
0
;
i
<
colors
.
length
;
i
++
)
{
$myCanvas
.
drawRect
({
fillStyle
:
colors
[
i
],
strokeStyle
:
'black'
,
strokeWidth
:
1
,
x
:
(
i
*
100
)
+
200
,
y
:
100
,
fromCenter
:
false
,
width
:
100
,
height
:
100
});
});
}
}
function
draw
(){
function
draw
(){
console
.
log
(
"Drawing"
);
colors
=
[];
// console.log(json);
$
.
ajax
({
var
$myCanvas
=
$
(
'#myCanvas'
);
dataType
:
"json"
,
for
(
var
i
=
0
;
i
<
colors
.
length
;
i
++
)
{
url
:
"colors.json"
,
$myCanvas
.
drawRect
({
mimeType
:
"application/json"
,
fillStyle
:
"#"
+
colors
[
i
],
success
:
function
(
data
){
strokeStyle
:
'blue'
,
var
img
=
new
Image
();
strokeWidth
:
0
,
img
.
onload
=
function
(){
x
:
(
i
*
100
)
+
200
,
y
:
200
,
var
height
=
img
.
height
;
fromCenter
:
false
,
var
width
=
img
.
width
;
width
:
100
,
var
xpos
=
0
height
:
100
if
(
width
/
2
<
50
*
data
.
colors
.
length
/
2
){
});
xpos
=
((
width
/
2
)
+
200
)
+
(
50
*
data
.
colors
.
length
/
2
)
}
}
else
{
xpos
=
((
width
/
2
)
+
200
)
-
(
50
*
data
.
colors
.
length
/
2
)
}
var
$myCanvas
=
$
(
'#myCanvas'
);
$myCanvas
.
drawImage
({
source
:
img
,
x
:
xpos
,
y
:
(
img
.
height
/
2
)
+
200
,
load
:
palette
});
// code here to use the dimensions
}
img
.
src
=
data
.
image
;
console
.
log
(
data
);
for
(
var
i
=
0
;
i
<
data
.
colors
.
length
;
i
++
)
{
colors
.
push
(
data
.
colors
[
i
]);
}
}});
palette
();
}
}
$
(
"document"
).
ready
(
draw
());
$
(
"document"
).
ready
(
draw
());
</script>
</script>
...
@@ -47,7 +82,7 @@
...
@@ -47,7 +82,7 @@
</head>
</head>
<body>
<body>
<canvas
id=
"myCanvas"
width=
"
1000"
height=
"1000
"
>
<canvas
id=
"myCanvas"
width=
"
2000"
height=
"5000"
onclick=
"draw()
"
>
</canvas>
</canvas>
</body>
</body>
...
...
colors.json
View file @
b1616c40
[
"6b97c1"
,
{
"a3b5d2"
,
"image"
:
"img.jpg"
,
"2c2c3e"
,
"colors"
:[
"#6795c0"
,
"#a4b5d3"
,
"#282434"
,
"#485471"
,
"#4774a0"
]
"435c7f"
,
}
"517da7"
\ No newline at end of file
]
\ No newline at end of file
img2.jpg
0 → 100644
View file @
b1616c40
245 KB
smalltest.jpg
0 → 100644
View file @
b1616c40
3.82 KB
src/main.rs
View file @
b1616c40
...
@@ -44,7 +44,9 @@ fn resize_image(img:&DynamicImage, maxpix: f64) -> DynamicImage{
...
@@ -44,7 +44,9 @@ fn resize_image(img:&DynamicImage, maxpix: f64) -> DynamicImage{
fn
main
()
{
fn
main
()
{
let
maxpix
=
100000.0
;
let
maxpix
=
100000.0
;
let
orig_img
=
image
::
open
(
"img.jpg"
)
.unwrap
();
let
clusters
:
usize
=
5
;
let
orig_img
=
image
::
open
(
"img2.jpg"
)
.unwrap
();
let
orig_dimensions
=
orig_img
.dimensions
();
let
orig_dimensions
=
orig_img
.dimensions
();
let
mut
img
=
orig_img
;
let
mut
img
=
orig_img
;
...
@@ -65,7 +67,7 @@ fn main() {
...
@@ -65,7 +67,7 @@ fn main() {
println!
(
"{:?} Total Pixels"
,(
dimensions
.
0
*
dimensions
.
1
)
as
usize
);
println!
(
"{:?} Total Pixels"
,(
dimensions
.
0
*
dimensions
.
1
)
as
usize
);
let
a
=
Matrix
::
new
((
dimensions
.
0
*
dimensions
.
1
)
as
usize
,
3
,
pixel_data
);
let
a
=
Matrix
::
new
((
dimensions
.
0
*
dimensions
.
1
)
as
usize
,
3
,
pixel_data
);
let
mut
model
=
KMeansClassifier
::
new
(
5
);
let
mut
model
=
KMeansClassifier
::
new
(
clusters
);
model
.train
(
&
a
)
.unwrap
();
model
.train
(
&
a
)
.unwrap
();
println!
(
"{:?}"
,
model
);
println!
(
"{:?}"
,
model
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment