Mathematica图像处理(6)--图片转字符串

前几天看到用python实现了将图片转换成字符串的

于是就准备用Matheatica来实现她

***********

原理:

1.把图片转成灰度图像

2.不同灰度值对应不同的符号

3.对一张图像上每一个点进行变换

*************

看一下效果

这是原图

这是效果图

效果一般吧 能看清大概


下面直接贴一下源码

file = "D:\\dmcs.jpg";
pic = Import[file];
pic = ColorConvert[pic, "Grayscale"];
pic = Thumbnail[pic, 100];
data = ImageData[pic];
color = " - - - + + + . . . 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 8 8 8 9 9 9 * * * # # #";
color = StringSplit[color];
closeMatch[c_] := color[[IntegerPart[c*100/2.5 + 1]]];
pic1 = Grid[
   Map[closeMatch, data, {2}]
   , Spacings -> {0, 0}];
Export["2.jpg", pic1]

2016/8/14

以上,所有



转载于:https://www.cnblogs.com/wmn7q/p/7265577.html

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
v1.6.3 @szhorvat szhorvat released this 25 days ago · 8 commits to master since this release More robust error checking and reporting Documentation improvements Downloads 1.02 MB MaTeX-1.6.3.paclet Source code (zip) Source code (tar.gz) v1.6.2 1ff11e8 v1.6.2 @szhorvat szhorvat released this on 20 Nov · 22 commits to master since this release The documentation is now integrated into the Documentation Center. Bug fix: full compatibility with Mathematica 10.0 restored. (Note: Re-released on 2016-11-20 with documentation fixes but no modifications to the package.) Downloads 504 KB MaTeX-1.6.2.paclet Source code (zip) Source code (tar.gz) v1.6.1 30633ef v1.6.1 @szhorvat szhorvat released this on 30 Aug · 29 commits to master since this release Bug fix: better error checking for the CacheSize option. Downloads 10.5 KB MaTeX-1.6.1.zip Source code (zip) Source code (tar.gz) v1.6.0 f2852e2 v1.6.0 @szhorvat szhorvat released this on 20 Aug · 32 commits to master since this release MaTeX now threads over lists. A list is batch-processed using a single run of LaTeX, which is much faster than element-wise processing. Implemented by Andreas Ahlrichs. Note that this changes behaviour slightly. Previous versions of MaTeX compiled MaTeX[{1, x^2, x/2}] as a single expression. Now each element of the list is converted to a separate result. To restore the old behaviour, apply TeXForm explicitly: MaTeX[TeXForm[{1, x^2, x/2}]. Expressions with head TeXForm are now automatically handled. Bug fixes: Better handling of CR/LF line endings and character encodings. Downloads 10.5 KB MaTeX-1.6.0.zip Source code (zip) Source code (tar.gz) v1.5.0 a2b4aad v1.5.0 @szhorvat szhorvat released this on 19 Jun · 49 commits to master since this release Much improved LaTeX error reporting. Please report any problems you notice with the new err
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值