词语肖像的可视化[英] Word Portraits visualization

本文是小编为大家收集整理的关于词语肖像的可视化的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我在这个可视化中停下来,它被称为 Word Portrait:

在此处输入图片描述

我的问题是:如何做这样的事情?有没有介绍这个的教程或论文?

推荐答案

我较新看到了这个,但我过去做过类似的位图到 ASCII 艺术转换器.所以从我的角度来看,我是这样看的:

  1. 获取灰度图像并对其进行分割(按固定纵横比的矩形区域)

    宽高比由输入的文本短语和使用的字体给出.这将为您提供具有相似颜色的矩形列表,以便计算它们的平均颜色.另外一个好主意是限制段的最小和最大大小

    • 太小的矩形不可读
    • 太大的矩形很丑(见最大的天才)
  2. 用文本替换矩形段

    字体大小受填充区域(矩形大小)的限制,因此文本将适合其中.文本的平均颜色应与矩形段的平均颜色相同

    text_color=rectangle_avg_color*(ink_pixels+paper_pixels)/ink_pixels
    

    ink_pixels 和 paper_pixels 是渲染文本短语中的像素数.如果您想实现彩色图像,那么只需分别计算 R、G、B 值并将其混合在一起或一次按颜色和强度进行分割

请参阅图像到 ASCII 艺术的转换,它可能对您有所帮助一些新想法...

本文地址:https://www.itbaoku.cn/post/627329.html

问题描述

I stopped by this visualization and it's called Word Portrait:

enter image description here

My question is: how to do something like this? Is there a tutorial or a paper that describes this?

推荐答案

I newer saw this but I did bitmap to ASCII art converter in the past which is similar. so from my point of view I see it like this:

  1. take gray-scale image and segmentate it (by rectangle areas with fixed aspect ratio)

    Aspect ratio is given by input text phrase and Font used. This will give you list of rectangles with similar colors so compute average color for them. Also a good idea is to limit min and max size of segments

    • too small rectangles are unreadable
    • too big rectangles are ugly (see the biggest GENIUS)
  2. replace rectangle segments by text

    Font size is limited by filled area (rectangle size) so text will fit into it. Average color of text should be the same as average color of rectangle segment

    text_color=rectangle_avg_color*(ink_pixels+paper_pixels)/ink_pixels
    

    ink_pixels and paper_pixels are the count of pixels in rendered text phrase. If you want to implement colored images then just compute R,G,B values separately and blend it together or segmentate by colors and intensities at once

See Image to ASCII Art conversion it may help you got some new ideas ...