SourceForge logo
SourceForge logo
Menu

Re: [Matplotlib-users] XKCD style graphs?

From: Damon M. <dam...@gm...> - 2012年10月04日 14:54:31
On Thu, Oct 4, 2012 at 3:35 PM, Pierre Haessig <pie...@cr...> wrote:
> Le 04/10/2012 16:03, Jason Grout a écrit :
>> f@r means f(r)
>>
>> a~ImageConvolve~b means ImageConvolve(a,b) (~ treats an operator as infix)
>>
>> Table[..., {2}] means [... for i in range(2)]
>>
>> #+1& is a lambda function lambda x: x+1
>>
>> So I think it goes something like:
>>
>> def xkcdDistort(p):
>> r = ImagePad(Rasterize(p), 10, Padding='White')
>> (ix, iy) = [ImageConvolve(RandomImage([-1,1], ImageDimensions(r)),
>> GaussianMatrix(10))
>> for i in range(2)]
>> return ImagePad(ImageTransformation(r,
>> lambda coord: (coord[0]+15*ImageValue(ix, coord),
>> coord[1]+15*ImageValue(iy, coord)),
>> DataRange='Full'),
>> -5)
> Thanks a lot!
>
> It's the first time I encounter Mathematica syntax. Some of these
> functional notations are not so easy to follow for my unexperienced eyes
> but it makes this Mathematica code nicely compact.
>
> So I think this code indeed resamples the rastered plot image on a
> shaken coordinate grid. I kind of understand that the noise on
> coordinates is spatially smoothed by a 10px Gaussian Point Spread
> Function (if I understand correctly...)
>
> Best,
> Pierre
Adding Gaussian noise to each point on a function doesn't look nice.
That's why I produced a random function in Fourier space first. That
way, random functions still have some sense of smoothness.
-- 
Damon McDougall
http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /