-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathphash.ijs
More file actions
30 lines (23 loc) · 712 Bytes
/
Copy pathphash.ijs
File metadata and controls
30 lines (23 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
load 'media/imagekit'
load 'stats/base'
load '~addons/media/imagekit/color_space.ijs'
load '~addons/media/imagekit/filter.ijs'
atIndex =: 4 : 0
N =. 32
cos =. 2 & o.
(%: (2 % N)) * cos (((2 * x + 1) * y * 1p1) % (2 * N))
)
NB. coefficients of the 32x32 DCT matrix
coeffs =: (i.32) atIndex " 0 / (i.32)
matmul =: +/ .*
dct =: (coeffs & matmul) @: (matmul & (|: coeffs))
NB. resize to 32x32
resize_32 =: 3 : 0
sz =. 2 {. $y
ind =. (<"0 sz%(32 32)) <.@*&.> <@i."0 (32 32)
(<ind) { y
)
crop_8 =: (< (i.8);(i.8)) { ]
grayscale =: ((0 & {) " 1) @: RGB_to_YUV
NB. median filter might be why it's slower
phash =: (median > ]) @: , @: crop_8 @: dct @: resize_32 @: (7 medianf) @: grayscale