Commit 90e0d1e9 authored by Mario Andres Serruya's avatar Mario Andres Serruya
Browse files

redis-python pseudoimss-python image pipelines achieved

parent 1b7dcf9d
No related merge requests found
Showing with 32 additions and 22 deletions
+32 -22
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(type(clouds))
clouds = io.imread(filename)
t0 = time.clock()
clouds = pickle.dumps(clouds)
t1 = time.clock() - t0
print(t1)
#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)
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)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment