up [pdf]
from rsf.proj import *

# Download data
Fetch('mona.img','imgs')

# Convert to standard format
Flow('mona','mona.img',
     '''
     echo n1=512 n2=513 in=$SOURCE data_format=native_uchar |
     dd type=float
     ''',stdin=0)

Result('mona',
       '''
       grey transp=n allpos=y title="Mona Lisa"
       color=b screenratio=1 wantaxis=n
       ''')

Result('edge','mona',
       '''
       canny | dd type=float | 
       grey allpos=y title="Edge Detector" transp=n screenratio=1 wantaxis=n
       ''')

# Edge preserving smoothing

rect=80 # smoothing radius

Flow('mona2','mona','impl2 rect1=%d rect2=%d tau=1' % (rect,rect))

Result('mona2',
       '''
       grey transp=n allpos=y title="Smoothed"
       color=b screenratio=1 wantaxis=n
       ''')

Result('edge2','mona2',
       '''
       canny | dd type=float | 
       grey allpos=y title="Edge Detector" transp=n screenratio=1 wantaxis=n
       ''')

# Patch to run in parallel

Flow('patch','mona','patch w=200,200 p=3,3 | put n3=9 n4=1')

Flow('patch2','patch','impl2 rect1=%d rect2=%d tau=1' % (rect,rect),
     split=[4,'omp'])

Flow('pmona2','patch2','put n3=3 n4=3 | patch inv=y weight=y')

Result('pmona2',
       '''
       grey transp=n allpos=y title="Smoothed (with Patching)"
       color=b screenratio=1 wantaxis=n
       ''')

End()

sfdd
sfgrey
sfcanny
sfimpl2
sfpatch
sfput
sfomp

data/imgs/mona.img