Esempio n. 1
0
def compressed_image():
    img = Image.open('compressed_image.jpg')
    fig = plt.figure()
    ax = Subplot(fig, 111)
    ax.imshow(img, cmap="gray")
    fig.add_subplot(ax)

    output = io.BytesIO()
    FigureCanvas(fig).print_jpg(output)
    return Response(output.getvalue(), mimetype='image/jpg')
Esempio n. 2
0
    def words_in_topic(self, i_topic: int, axis: Subplot) -> AxesImage:
        """Plot the relative importance of words in a given topic.

        Parameters
        ----------
        i_topic: int
            Index of the topic to plot. Numbering starts at 0.
        axis: Subplot
            The matplotlib axis to plot into.

        Returns
        -------
        AxesImage
            The image with the produced word cloud.

        """
        word_given_topic = dict(self.__word_given_topic[i_topic])
        wordcloud = self.__wordcloud.generate_from_frequencies(word_given_topic)
        axis.set_title(f'Topic {i_topic}')
        axis.set_axis_off()
        return axis.imshow(wordcloud, interpolation='bilinear')