In [64]:
#!/usr/bin/env python

import skimage
import skimage.io
import skimage.transform

import os
import scipy as scp
import scipy.misc

import numpy as np
import tensorflow as tf

import fcn32_vgg
import utils

from tensorflow.python.framework import ops

#os.environ['CUDA_VISIBLE_DEVICES'] = ''

#img1 = skimage.io.imread("./test_data/tabby_cat.png")
img1 = skimage.io.imread("./test_data/19.jpg")

In [65]:
from PIL import Image
%matplotlib inline
#%matplotlib qt

from skimage import io, img_as_ubyte

io.imshow(img1)


Out[65]:
<matplotlib.image.AxesImage at 0x98b3710>

In [51]:
img1_obj = skimage.io.imread("./test_data/19_object.png")
io.imshow(img1_obj)


Out[51]:
<matplotlib.image.AxesImage at 0x8ab9d10>

In [52]:
print img1_obj.shape

labels = np.zeros((img1_obj.shape[0],img1_obj.shape[1]))


(333, 500, 3)

In [ ]:


In [56]:
bg = np.where((img1_obj[:,:,0]==0) & (img1_obj[:,:,1]==0) & (img1_obj[:,:,2]==0))
obj = np.where((img1_obj[:,:,0] > 0) & (img1_obj[:,:,1]==0) & (img1_obj[:,:,2]==0))

In [57]:
print img1_obj[180,250,:]


[128   0   0]

In [58]:
print len(bg[0])
print len(obj[0])


138390
20885

In [59]:
labels[obj[0],obj[1]]=1

In [63]:
io.imshow(labels)

img = Image.fromarray(img_as_ubyte(labels)).convert('RGB')
img.save('./test_data/labels.png', "PNG", quality=80)


/home/irashadow/env_TensorFlow/lib/python2.7/site-packages/skimage/util/dtype.py:110: UserWarning: Possible precision loss when converting from float64 to uint8
  "%s to %s" % (dtypeobj_in, dtypeobj))

In [4]:


In [5]:


In [ ]: