Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
10
Task/Image-convolution/J/image-convolution-1.j
Normal file
10
Task/Image-convolution/J/image-convolution-1.j
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
NB. pad the edges of an array with border pixels
|
||||
NB. (increasing the first two dimensions by 1 less than the kernel size)
|
||||
pad=: adverb define
|
||||
'a b'=. (<. ,. >.) 0.5 0.5 p. $m
|
||||
a"_`(0 , ] - 1:)`(# 1:)}~&# # b"_`(0 , ] - 1:)`(# 1:)}~&(1 { $) #"1 ]
|
||||
)
|
||||
|
||||
kernel_filter=: adverb define
|
||||
($m)+/ .*&(,m)&(,/);._3 m pad
|
||||
)
|
||||
7
Task/Image-convolution/J/image-convolution-2.j
Normal file
7
Task/Image-convolution/J/image-convolution-2.j
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
NB. kernels borrowed from C and TCL implementations
|
||||
sharpen_kernel=: _1+10*4=i.3 3
|
||||
blur_kernel=: 3 3$%9
|
||||
emboss_kernel=: _2 _1 0,_1 1 1,:0 1 2
|
||||
sobel_emboss_kernel=: _1 _2 _1,0,:1 2 1
|
||||
|
||||
'blurred.ppm' writeppm~ blur_kernel kernel_filter readppm 'original.ppm'
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
NB. pad the first n dimensions of an array with zeros
|
||||
NB. (increasing all dimensions by 1 less than the kernel size)
|
||||
pad=: adverb define
|
||||
adj1=: <.m%2
|
||||
adj2=: m-1
|
||||
(-@(adj2 + ]) {. (adj1 + ]) {. [) (#m) {. $
|
||||
)
|
||||
|
||||
kernel_filter=: adverb define
|
||||
[: ,/"(-#$m) ($m) +/@(,/^:(_1+#$m))@:*&m;._3 ($m)pad
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue