【问题标题】:Image manipulation with Mathematica使用 Mathematica 进行图像处理
【发布时间】:2011-06-13 17:14:33
【问题描述】:

我在my previous post 之后创建了这个主题。我无法运行以下代码(由@belisarius 编写):

a = Image["path/file.png"]
b = Image@ArrayPad[ImageData@a, {{40, 0}, {40}, {0}}, {1, 1, 1}];
f[image_, angleMult_] := ImageForwardTransformation[image, (
    fi = ArcTan[Abs[#[[2]]/(#[[1]] - .5)]];
    fi1 = angleMult fi (#[[1]]^2 + #[[2]]^2)/2;
    {(1/2 - Sin[fi1] #[[2]] - Cos[fi1]/2 + 
       Cos[fi1] #[[1]]), -Sin[fi1]/2 + Sin[fi1] #[[1]] + 
      Cos[fi1] #[[2]]}) &]
t = Table[f[b, x], {x, 0, .2, .02}];
t1 = Reverse@t;
Export["anim.gif", Join[t, t1], "DisplayDurations" -> .15];
Import["anim.gif", "Animation"]

这里是错误列表:

ArrayPad::depth: Padding amount {{40,0},{40},{0}} should specify padding in no more than the number of dimensions in array {{1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,0.996078,0.984314,<<142>>},<<49>>,<<145>>}. >>

Image::imgarray: The specified argument ArrayPad[{{1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,0.996078,0.984314,<<142>>},<<49>>,<<145>>},{{40,0},{40},{0}},{1,1,1}] should be an array of rank 2 or 3 with machine-sized numbers. >>

ImageForwardTransformation::imginv: Expecting an image or graphics instead of Image[ArrayPad[{{1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,0.996078,0.984314,<<142>>},<<49>>,<<145>>},{<<1>>},{1,1,1}]]. >>

General::stop: Further output of ImageForwardTransformation::imginv will be suppressed during this calculation. >>

Rasterize::bigraster: Not enough memory available to rasterize ImageForwardTransformation expression. >>

General::stop: Further output of Rasterize::bigraster will be suppressed during this calculation. >>

我在 Linux 下使用 Mathematica 8。

【问题讨论】:

  • 我自己在 Windows 上使用 Mma,但我在 Google 上搜索了将图像粘贴到 Linux on Mma 并找到了这个。你可以试试mathkb.com/Uwe/Forum.aspx/mathematica/16019/…
  • 开始调试,把第二条命令中的b=...换成b=a,看看是不是图片格式问题。

标签: linux wolfram-mathematica


【解决方案1】:

我想我明白了。

上面的代码适用于彩色图像(3 个通道),您似乎正试图在黑白图像(1 个通道)上运行它。

使用彩色图像或将第二行替换为:

b = Image@ArrayPad[ImageData@a, {{40, 0}, {40}}, 1];

这是使用上述替换的图像的结果:

a = Binarize[Image["path/file.png"]]
b = Image@ArrayPad[ImageData@a, {{40, 0}, {40}}, 1];

【讨论】:

    猜你喜欢
    • 2012-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-28
    相关资源
    最近更新 更多