2011-01-22 110 views
1

我在my previous post之後創建了此主題。我不能運行下面的代碼(由@belisarius書面):使用Mathematica進行圖像處理

a = Image["path/file.png"] 
b = [email protected][[email protected], {{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 = [email protected]; 
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. >> 

我使用Mathematica 8 Linux下。

+1

我使用MMA的在Windows自己,但我做了一個谷歌搜索粘貼到Mma的Linux圖像,並發現這一點。這可能是你可以嘗試http://www.mathkb.com/Uwe/Forum.aspx/mathematica/16019/Paste-image-directly-into-V7-notebook-on-Linux-X11 – dbjohn 2011-01-22 16:37:50

回答

5

我想我明白了。

上面的代碼是用於彩色圖像(3通道),看起來您正試圖通過B圖像(1通道)運行它。

要麼使用的彩色圖像或通過替換的第二行:

b = [email protected][[email protected], {{40, 0}, {40}}, 1]; 

下面是使用上述替換作爲圖片的結果:

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

alt text