Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
Open sidebar
Mario Andres Serruya
REDIS_TESTS
Commits
90e0d1e9
Commit
90e0d1e9
authored
4 years ago
by
Mario Andres Serruya
Browse files
Options
Download
Email Patches
Plain Diff
redis-python pseudoimss-python image pipelines achieved
parent
1b7dcf9d
master
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python/pseudo_imss.py
+26
-22
python/pseudo_imss.py
python/redis_cli.py
+6
-0
python/redis_cli.py
with
32 additions
and
22 deletions
+32
-22
python/
ctypes_test
.py
→
python/
pseudo_imss
.py
+
26
-
22
View file @
90e0d1e9
import
ctypes
from
ctypes
import
*
import
pathlib
import
skimage
import
pickle
import
numpy
as
np
import
os
from
skimage
import
io
,
filters
from
io
import
StringIO
import
ctypes
,
pathlib
import
skimage
,
pickle
import
numpy
as
np
import
time
from
io
import
StringIO
from
ctypes
import
*
from
skimage
import
io
,
filters
from
skimage.color
import
rgb2gray
,
rgba2rgb
##############################################
...
...
@@ -17,20 +17,18 @@ libname = header_dir / "liblittle_lib.so"
c_lib
=
ctypes
.
CDLL
(
libname
)
##############################################
############### STORE AN IMAGE ###############
################ STORE IMAGE #################
t_init
=
time
.
clock
()
#Retrieve the concerning image.
#image_file = open('./clouds.jpg', 'rb')
#image_buffer = image_file.read()
#buffer_length = len(image_buffer)
#Load directory.
filename
=
os
.
path
.
join
(
'.'
,
'clouds.jpg'
)
#Read the image.
clouds
=
io
.
imread
(
filename
)
clouds
=
pickle
.
dumps
(
clouds
)
print
(
t
ype
(
clouds
)
)
clouds
=
io
.
imread
(
filename
)
t0
=
time
.
clock
(
)
clouds
=
pickle
.
dumps
(
clouds
)
t1
=
time
.
clock
()
-
t0
print
(
t
1
)
#Size of the concerning image.
clouds_len
=
len
(
clouds
)
#Specify return parameters.
c_lib
.
set_data
.
restype
=
ctypes
.
c_int32
...
...
@@ -51,13 +49,19 @@ answer = c_lib.get_data(return_buffer)
##############################################
############## TRANSFORM IMAGE ###############
clouds_from_c
=
pickle
.
loads
(
return_buffer
)
#Read the image.
#clouds = io.imread(qwertyu)
t0
=
time
.
clock
()
clouds_from_c
=
pickle
.
loads
(
return_buffer
)
t1
=
time
.
clock
()
-
t0
print
(
t1
)
#Turn it to grayscale.
clouds_from_c
=
rgb2gray
(
clouds_from_c
)
#
Apply
a simple threshold.
#
Determine
a simple threshold.
threshold
=
filters
.
threshold_otsu
(
clouds_from_c
)
#Apply the former.
image_thesholded
=
clouds_from_c
>
threshold
#Save the files.
io
.
imsave
(
"clouds_test.png"
,
image_thesholded
)
t_end
=
time
.
clock
()
-
t_init
print
(
t_end
)
This diff is collapsed.
Click to expand it.
python/redis_cli.py
+
6
-
0
View file @
90e0d1e9
import
os
import
pickle
import
skimage
import
time
import
numpy
as
np
from
skimage
import
io
,
filters
from
skimage.color
import
rgb2gray
...
...
@@ -26,6 +27,8 @@ rc = RedisCluster(startup_nodes = startup_nodes, decode_responses = False)
###################################### READ AN IMAGE ######################################
###########################################################################################
t_init
=
time
.
clock
()
#Load directory.
filename
=
os
.
path
.
join
(
'.'
,
'clouds.jpg'
)
#Read the image.
...
...
@@ -41,3 +44,6 @@ threshold = filters.threshold_otsu(clouds_from_redis)
image_thesholded
=
clouds_from_redis
>
threshold
#Save the files.
io
.
imsave
(
"clouds_test.png"
,
image_thesholded
)
t_end
=
time
.
clock
()
-
t_init
print
(
t_end
)
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets