V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
lawlietxxl
V2EX  ›  程序员

周末用 c++ opencv 撸了一个像素画工具(初衷是看到之前七夕节礼物问题,想到这个 idea)

  •  
  •   lawlietxxl · 2016-08-07 18:23:22 +08:00 · 3210 次点击
    这是一个创建于 2826 天前的主题,其中的信息可能已经有所发展或是发生改变。

    效果

    处理前图片

    灰度模式

    RGB 模式

    测试&开发环境

    • ubuntu16.04
    • opencv 3.10

    算法

    算法是比较简单的,以 PIXEL_LENGTH 为单位处理每张图片的时候,计算 PIXEL_LENGTH*PIXEL_LENGTH 这块地方的平均值。然后读入图片库文件夹,为每张图片的整体计算平均值,放入 map 中。

    然后将已经像素化的图片进行填充,填充时,每个像素会扩张为均值最接近的 SINGLE_PIC_LENGTH 边长的正方形。

    目的

    之前看到七夕节礼物,想到这个 idea 。可以用两个人的很多照片,组合成一张女朋友 /男朋友的 像素画,然后打印一张比较大的,啧啧,画美不看

    地址

    https://github.com/lawlietxxl/phixel

    满地打滚求 star 啦啦啦~~

    20 条回复    2016-08-09 13:47:07 +08:00
    lawlietxxl
        1
    lawlietxxl  
    OP
       2016-08-07 18:24:27 +08:00
    可能是我下载的图片库都是些黄瓜青菜。。所以狗狗泛绿光了。。 RGB 选择图片的时候加入了随机的
    lazydao
        2
    lazydao  
       2016-08-07 18:39:26 +08:00 via Android
    第一次玩 opencv ?
    lawlietxxl
        3
    lawlietxxl  
    OP
       2016-08-07 18:45:50 +08:00
    @lazydao 恩。
    techme
        4
    techme  
       2016-08-07 18:59:04 +08:00
    连连看?
    andyhuzhill
        5
    andyhuzhill  
       2016-08-07 19:01:41 +08:00
    第一次看到类似的东西 还是在 Matrix67 大牛的博客中  Matrix67 用  AV 截图拼了一个自己的头像
    lawlietxxl
        6
    lawlietxxl  
    OP
       2016-08-07 19:30:28 +08:00 via iPhone
    @andyhuzhill 哈哈 很可以
    hitmanx
        7
    hitmanx  
       2016-08-07 20:20:02 +08:00 via iPhone
    有点意思。有个问题,你估算过最后要打印多大的照片才能看清比如你这幅图中的每一幅小照片?
    lawlietxxl
        8
    lawlietxxl  
    OP
       2016-08-07 20:22:48 +08:00
    @hitmanx 我觉得这个也不需要看的太清楚吧 哈哈 本来就是个朦胧模糊美 太清楚了不就没意思啦
    ibigbug
        9
    ibigbug  
       2016-08-08 01:17:34 +08:00
    这个,当礼物会不会被分手?
    lawlietxxl
        10
    lawlietxxl  
    OP
       2016-08-08 08:02:36 +08:00 via iPhone
    @ibigbug 为什么。。。。
    lzx1413
        11
    lzx1413  
       2016-08-08 14:02:23 +08:00
    密集恐惧者怎么办。。。
    lawlietxxl
        12
    lawlietxxl  
    OP
       2016-08-08 14:14:41 +08:00
    @lzx1413 恩。。我也觉得。。我刚刚吐了回来。。
    lawlietxxl
        13
    lawlietxxl  
    OP
       2016-08-08 14:15:15 +08:00
    @lzx1413 所以建议把图片像素化的时候稀疏一点。。。
    skywinger
        14
    skywinger  
       2016-08-08 17:37:53 +08:00
    之前用 opencv 做图片相似度匹配, opencv 还是不错的东东。搞这个有点密集恐惧的感觉
    ilotuo
        15
    ilotuo  
       2016-08-08 22:36:51 +08:00 via Android
    建议定制成那种像素糖更有意思
    lawlietxxl
        16
    lawlietxxl  
    OP
       2016-08-08 23:43:58 +08:00
    @ilotuo 举个例子图,兄弟?
    ilotuo
        17
    ilotuo  
       2016-08-09 00:06:45 +08:00
    @lawlietxxl 淘宝搜索 像素糖
    ibigbug
        18
    ibigbug  
       2016-08-09 00:26:20 +08:00
    @lawlietxxl 好密集恐惧啊,女孩子会喜欢嘛
    mozartgho
        19
    mozartgho  
       2016-08-09 11:52:00 +08:00
    挺有意思的!
    lawlietxxl
        20
    lawlietxxl  
    OP
       2016-08-09 13:47:07 +08:00
    @ibigbug 是特瞄的有点可怕!我想想怎么能改善一哈
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2098 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 16:03 · PVG 00:03 · LAX 09:03 · JFK 12:03
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.