Skip to content

Commit

Permalink
Semantic segmentation correctly working!
Browse files Browse the repository at this point in the history
  • Loading branch information
nikkonrom committed Nov 26, 2017
1 parent 0b3be8a commit d0a2689
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions python/semantic_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from python.operation import *
from scipy import ndimage as ndi
import matplotlib.pyplot as plt

import matplotlib as mpl
from skimage.morphology import watershed, disk
from skimage import data
from skimage.filters import rank
Expand All @@ -22,12 +22,20 @@ def execute(input_pixmap):
gradient = rank.gradient(denoised, disk(2))

labels = watershed(gradient, markers)
plt.subplots_adjust(0, 0, 1, 1)
img_plot = plt.imshow(labels, cmap=plt.cm.spectral, interpolation='nearest', alpha=.7, aspect=None)

figure = plt.figure(frameon=False)
ax = plt.Axes(figure, [0., 0., 1., 1.])
ax.set_axis_off()
figure.add_axes(ax)
size = (input_pixmap.width() / 100, input_pixmap.height() / 100)
figure.set_size_inches(size)
extent = mpl.transforms.Bbox(((0,0), size))

ax.imshow(labels, cmap=plt.cm.spectral, interpolation='nearest')

buffer = io.BytesIO()
img_plot.figure.savefig(buffer, format='png')
figure.savefig(buffer, bbox_inches=extent, pad_inches=0, format='png')
buffer.seek(0)
output = Image.open(buffer)
# imgplot.show()
return QPixmap.fromImage(image_to_qimage(output))

return QPixmap.fromImage(image_to_qimage(output))

0 comments on commit d0a2689

Please sign in to comment.