image_filter_dsl 0.0.1 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +194 -0
- data/lib/image_filter_dsl.rb +2 -2
- data/lib/image_filter_dsl/binary/serialize.rb +4 -2
- data/lib/image_filter_dsl/binary/struct.rb +2 -2
- data/lib/image_filter_dsl/dsl/filter.rb +3 -3
- data/lib/image_filter_dsl/dsl/filter_instructions.rb +74 -22
- data/lib/image_filter_dsl/dsl/kernel.rb +4 -2
- data/lib/image_filter_dsl/engine/image_processor.rb +5 -3
- data/lib/image_filter_dsl/engine/io.rb +7 -2
- metadata +72 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f36219d0037d3f5d26ca5d4aa9c06465964094c89afe256ad3d79e63dda611d6
|
4
|
+
data.tar.gz: 310be0964d3c2f293b43c2022437effbdefa1df00588d27b36743642c0502ac8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db69c17700799b782c73169fab41f56fcec07ba2695dcb15815eb8aa53944bc65af5684205a09f0bdc99164e01a6e24939fb15603375fd0cfc2991422bdcfa7a
|
7
|
+
data.tar.gz: 9b765299f432bab3d67d40ce3e29568461409ec83b394cb248979b4826d73dfe5e9a4c04d4a52c69208d73e4bcf863fe224d61029f5379d235eaae0d2bf89457
|
data/README.md
ADDED
@@ -0,0 +1,194 @@
|
|
1
|
+
# Image Filter DSL
|
2
|
+
|
3
|
+
_An Image Filter DSL (duh)_
|
4
|
+
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/image_filter_dsl.svg)](https://badge.fury.io/rb/image_filter_dsl)
|
6
|
+
|
7
|
+
{file:CHANGELOG.md Change Log}
|
8
|
+
|
9
|
+
## Features
|
10
|
+
|
11
|
+
- DSL with customizable input and output variables, and a set of basic instructions
|
12
|
+
- IO with serialization so Kernels can be written to binary files and loaded from binary files
|
13
|
+
- Image Processor that generates image file by applying Filter Kernel to every pixel of input image (supports multi-threading)
|
14
|
+
|
15
|
+
## DSL
|
16
|
+
|
17
|
+
### Filter Block
|
18
|
+
|
19
|
+
Using `ImageFilterDsl::Dsl::Filter`
|
20
|
+
|
21
|
+
|
22
|
+
# - First array contains input variables
|
23
|
+
# x, y, r, g, b, a, :width and :hght are automatically
|
24
|
+
# populated by image filter process
|
25
|
+
# - Second array contains output vars; r,g,b,a and optionally
|
26
|
+
# x,y for images
|
27
|
+
filter = Filter.define [:x,:y,:r,:g,:b], [:r,:g,:b] do
|
28
|
+
# Instructions go here
|
29
|
+
# instruction [input(s)], output
|
30
|
+
add [:x,:r], :g
|
31
|
+
|
32
|
+
# output can be an existing symbol in out, or a custom one up to 5 letters
|
33
|
+
# long (longer will be trimmed if serialized to a binary file)
|
34
|
+
|
35
|
+
# input can be any declared input or custom variable
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
### Instructions
|
40
|
+
|
41
|
+
Basic Use:
|
42
|
+
|
43
|
+
``instruction [argument1,argument2,...], :output_variable``
|
44
|
+
|
45
|
+
__Math__
|
46
|
+
|
47
|
+
- `add` add 2 or more input values, storing in output (<code>a+b</code>)
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
add [:r,5], :r # replace r with r + 5
|
51
|
+
```
|
52
|
+
|
53
|
+
- `mult` add 2 or more inputs, storing in out (<code>a*b</code>)
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
mult [:r,2], :r # Replace r with r * 2
|
57
|
+
```
|
58
|
+
|
59
|
+
- `div` divide 2 inputs
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
div [:r, 2], :g # Write r/2 to g
|
63
|
+
```
|
64
|
+
|
65
|
+
- `mod` store modulo of two inputs in output
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
mod [2,4], :t # Write 2$4 (2) to t
|
69
|
+
```
|
70
|
+
|
71
|
+
- `abs` store absolute value of input in output
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
abs [-5], :r # Writes abs(5) to r
|
75
|
+
```
|
76
|
+
|
77
|
+
__Collection__
|
78
|
+
|
79
|
+
- `min` store smallest of inputs in output (accepts 2 or more values)
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
min [:r,255,:g], :s # Writes smallest of r, 255 and g to s
|
83
|
+
```
|
84
|
+
|
85
|
+
- `max` store largest of inputs in output (accepts 2 or more values)
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
max [:r,0,:g], :s # Writes largest of r, 0 and g to s
|
89
|
+
```
|
90
|
+
|
91
|
+
- `avg` store average of inputs in output (accepts 2 or more values)
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
avg [:r,:g,:b], :ca # Writes (r+g+b)/3 to ca
|
95
|
+
```
|
96
|
+
|
97
|
+
|
98
|
+
__Logic/Conversion/Memory__
|
99
|
+
|
100
|
+
- `above` choose one of two values based on greater than comparison (4 values) `[n1,n1,true_val,false_val]`
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
# if r > g, store 0 in g, else store g in g (keep g the same)
|
104
|
+
above [:r,:g,0,:g], :g
|
105
|
+
```
|
106
|
+
|
107
|
+
- `below` choose one of two values based on less than comparison (4 values) `[n1,n1,true_val,false_val]`
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
# if r < g, store 0 in r, else store r in r (keep r the same)
|
111
|
+
below [:r,:g,0,:r], :r
|
112
|
+
```
|
113
|
+
|
114
|
+
- `switch` choose one of two values based on condition value (1/1.0 = true, 0/0.0 = false) `[cond,true_val,false_val]`
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
# If c is true, store r in a, else store g in a
|
118
|
+
switch [:c,:r,:g], :a
|
119
|
+
```
|
120
|
+
|
121
|
+
- `eq` if two input values are equal, store 1, else 0 (`[val1,val2]`)
|
122
|
+
- `bnot` if input is 1 or 1.0, store 0, else 1 (`[bool]`)
|
123
|
+
- `copy` copy input directly to output (`[src]`)
|
124
|
+
- `ceil` nearest whole integer of input, rounded up (`[val]`)
|
125
|
+
- `float` cast input to float (`[val]`)
|
126
|
+
- `round` round first input value to second value decimals (`[value,decimal_count]`)
|
127
|
+
- `mix` Mix two values together with a ratio (0*a + (1-r)*b) (`[ratio,a,b]`)
|
128
|
+
|
129
|
+
```ruby
|
130
|
+
# store (0.3*r) + (0.7*g) in b
|
131
|
+
mix [0.3,:r,:g], :b
|
132
|
+
```
|
133
|
+
|
134
|
+
__Generators__
|
135
|
+
|
136
|
+
- `rand` random float between min and max (`[min,max]`)
|
137
|
+
- `sin` sine function on single value
|
138
|
+
- `cos` cosine function on single value
|
139
|
+
- `tan` tangent function on single value
|
140
|
+
|
141
|
+
### Sample
|
142
|
+
|
143
|
+
Define filter
|
144
|
+
|
145
|
+
<!--```ruby-->
|
146
|
+
swizzle = Filter.define [:r,:g,:b], [:r,:g,:b] do
|
147
|
+
copy [:g], :t # copy green to temp
|
148
|
+
copy [:r], :g # copy red to green
|
149
|
+
copy [:b], :r # copy blue to red
|
150
|
+
copy [:t], :b # copy temp (original green) to blue
|
151
|
+
end
|
152
|
+
<!--```-->
|
153
|
+
|
154
|
+
Optionally write filter kernal to binary file on disk
|
155
|
+
|
156
|
+
<!--```ruby-->
|
157
|
+
ImageFilterDsl::Engine::IO.write("./swizzle.ifdk", swizzle)
|
158
|
+
<!--```-->
|
159
|
+
|
160
|
+
Use filter kernal to process image
|
161
|
+
|
162
|
+
<!--```ruby-->
|
163
|
+
# From binary kernal file
|
164
|
+
processor = ImageFilterDsl::Engine::ImageProcessor.new('./swizzle.ifdk')
|
165
|
+
# OR from filter object
|
166
|
+
processor = ImageFilterDsl::Engine::ImageProcessor.new(swizzle)
|
167
|
+
# or use aliases in main module
|
168
|
+
processor = ImageFilterDsl.image_processor(swizzle)
|
169
|
+
|
170
|
+
# Process image and store output
|
171
|
+
processor.process_image('./my_source.png', './my_output.png')
|
172
|
+
<!--```-->
|
173
|
+
|
174
|
+
- See `./sample_filters/samples.rb` for sample filters
|
175
|
+
- See Also: [image_filter_dsl_samples](https://bitbucket.org/WadeH/image_filter_dsl_samples/src/master/) for more samples
|
176
|
+
|
177
|
+
## Gem
|
178
|
+
|
179
|
+
Either
|
180
|
+
|
181
|
+
- Build into a gem using included `gemspec` file; includes CLI functionality
|
182
|
+
- Install using gem with `gem install image_filter_dsl`
|
183
|
+
|
184
|
+
## CLI
|
185
|
+
|
186
|
+
Image Filter DSL can be made to process an image from a binary kernal using
|
187
|
+
its CLI tool, `image_filter_dsl`
|
188
|
+
|
189
|
+
- Usage: `image_filter_dsl <kernel_file> <image_in> <image_out>`
|
190
|
+
|
191
|
+
## License
|
192
|
+
|
193
|
+
(c) 2018-2020, Wade H. (vdtdev.prod@gmail.com). All Rights Reserved.
|
194
|
+
Released under MIT license
|
data/lib/image_filter_dsl.rb
CHANGED
@@ -8,8 +8,8 @@ require_relative './image_filter_dsl/engine/image_processor.rb'
|
|
8
8
|
|
9
9
|
##
|
10
10
|
# Image Filter DSL Library
|
11
|
-
# (c) 2018 VDTDEV/Wade H. ~ MIT License
|
12
|
-
# @author Wade H. <vdtdev@gmail.com>
|
11
|
+
# (c) 2018-2020 VDTDEV/Wade H. ~ MIT License
|
12
|
+
# @author Wade H. <vdtdev.prod@gmail.com>
|
13
13
|
module ImageFilterDsl
|
14
14
|
|
15
15
|
##
|
@@ -1,8 +1,10 @@
|
|
1
1
|
##
|
2
2
|
# Image Filter DSL Library
|
3
|
-
# (c) 2018 VDTDEV/Wade H. ~ MIT License
|
4
|
-
# @author Wade H. <vdtdev@gmail.com>
|
3
|
+
# (c) 2018-2020 VDTDEV/Wade H. ~ MIT License
|
4
|
+
# @author Wade H. <vdtdev.prod@gmail.com>
|
5
5
|
module ImageFilterDsl
|
6
|
+
##
|
7
|
+
# Module containing binary kernal related logic
|
6
8
|
module Binary
|
7
9
|
##
|
8
10
|
# Module providing serialization functionality for converting between
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'bindata'
|
2
2
|
##
|
3
3
|
# Image Filter DSL Library
|
4
|
-
# (c) 2018 VDTDEV/Wade H. ~ MIT License
|
5
|
-
# @author Wade H. <vdtdev@gmail.com>
|
4
|
+
# (c) 2018-2020 VDTDEV/Wade H. ~ MIT License
|
5
|
+
# @author Wade H. <vdtdev.prod@gmail.com>
|
6
6
|
module ImageFilterDsl
|
7
7
|
module Binary
|
8
8
|
##
|
@@ -1,7 +1,7 @@
|
|
1
1
|
##
|
2
2
|
# Image Filter DSL Library
|
3
|
-
# (c) 2018 VDTDEV/Wade H. ~ MIT License
|
4
|
-
# @author Wade H. <vdtdev@gmail.com>
|
3
|
+
# (c) 2018-2020 VDTDEV/Wade H. ~ MIT License
|
4
|
+
# @author Wade H. <vdtdev.prod@gmail.com>
|
5
5
|
module ImageFilterDsl
|
6
6
|
module Dsl
|
7
7
|
##
|
@@ -12,7 +12,7 @@ module ImageFilterDsl
|
|
12
12
|
# Define method
|
13
13
|
# @param [Array] ins Input symbols
|
14
14
|
# @param [Array] outs Output symbols
|
15
|
-
# @param [Proc]
|
15
|
+
# @param [Proc] block Filter instructions body
|
16
16
|
# @return [FilterKernel] new Filter Kernel
|
17
17
|
def self.define(ins,outs,&block)
|
18
18
|
kernel = Kernel::FilterKernel.new(ins,outs)
|
@@ -1,8 +1,11 @@
|
|
1
1
|
##
|
2
2
|
# Image Filter DSL Library
|
3
|
-
# (c) 2018 VDTDEV/Wade H. ~ MIT License
|
4
|
-
# @author Wade H. <vdtdev@gmail.com>
|
3
|
+
# (c) 2018-2020 VDTDEV/Wade H. ~ MIT License
|
4
|
+
# @author Wade H. <vdtdev.prod@gmail.com>
|
5
5
|
module ImageFilterDsl
|
6
|
+
##
|
7
|
+
# Module defining DSL
|
8
|
+
# {include:file:dsl.md}
|
6
9
|
module Dsl
|
7
10
|
##
|
8
11
|
# Module defining filter kernel instruction logic
|
@@ -31,7 +34,13 @@ module ImageFilterDsl
|
|
31
34
|
round: 0xd6,
|
32
35
|
switch: 0xd7,
|
33
36
|
eq: 0xd8,
|
34
|
-
bnot: 0xd9
|
37
|
+
bnot: 0xd9,
|
38
|
+
mix: 0xda,
|
39
|
+
# generation
|
40
|
+
rand: 0xf0,
|
41
|
+
sin: 0xf1,
|
42
|
+
cos: 0xf2,
|
43
|
+
tan: 0xf3
|
35
44
|
}
|
36
45
|
|
37
46
|
##
|
@@ -40,7 +49,7 @@ module ImageFilterDsl
|
|
40
49
|
|
41
50
|
##
|
42
51
|
# Add instruction
|
43
|
-
# @param [Array] input values
|
52
|
+
# @param [Array] i input values
|
44
53
|
# @return [Integer|Float] output value
|
45
54
|
def self.add(i)
|
46
55
|
i.sum
|
@@ -48,7 +57,7 @@ module ImageFilterDsl
|
|
48
57
|
|
49
58
|
##
|
50
59
|
# Multiply instruction
|
51
|
-
# @param [Array] input values
|
60
|
+
# @param [Array] i input values
|
52
61
|
# @return [Integer|Float] output value
|
53
62
|
def self.mult(i)
|
54
63
|
v=1;
|
@@ -58,14 +67,14 @@ module ImageFilterDsl
|
|
58
67
|
|
59
68
|
##
|
60
69
|
# Multiply instruction
|
61
|
-
# @param [Array] input values
|
70
|
+
# @param [Array] i input values
|
62
71
|
# @return [Integer|Float] output value
|
63
72
|
def self.div(i)
|
64
73
|
i[0]/i[1]
|
65
74
|
end
|
66
75
|
##
|
67
76
|
# Calculate modulo
|
68
|
-
# @param [Array] input values
|
77
|
+
# @param [Array] i input values
|
69
78
|
# @return [Integer|] output value
|
70
79
|
def self.mod(i)
|
71
80
|
i[0] % i[1]
|
@@ -73,7 +82,7 @@ module ImageFilterDsl
|
|
73
82
|
|
74
83
|
##
|
75
84
|
# Absolute value
|
76
|
-
# @param [Array] input value
|
85
|
+
# @param [Array] i input value
|
77
86
|
# @return [Integer|Float] output value
|
78
87
|
def self.abs(i)
|
79
88
|
i[0].abs
|
@@ -81,7 +90,7 @@ module ImageFilterDsl
|
|
81
90
|
|
82
91
|
##
|
83
92
|
# Minimum instruction
|
84
|
-
# @param [Array] input values
|
93
|
+
# @param [Array] i input values
|
85
94
|
# @return [Integer|Float] output value
|
86
95
|
def self.min(i)
|
87
96
|
i.min
|
@@ -89,7 +98,7 @@ module ImageFilterDsl
|
|
89
98
|
|
90
99
|
##
|
91
100
|
# Maximum instruction
|
92
|
-
# @param [Array] input values
|
101
|
+
# @param [Array] i input values
|
93
102
|
# @return [Integer|Float] output value
|
94
103
|
def self.max(i)
|
95
104
|
i.max
|
@@ -97,7 +106,7 @@ module ImageFilterDsl
|
|
97
106
|
|
98
107
|
##
|
99
108
|
# Average instruction
|
100
|
-
# @param [Array] input values
|
109
|
+
# @param [Array] i input values
|
101
110
|
# @return [Integer|Float] output value
|
102
111
|
def self.avg(i)
|
103
112
|
i.sum / (1.0 * i.length)
|
@@ -105,7 +114,7 @@ module ImageFilterDsl
|
|
105
114
|
|
106
115
|
##
|
107
116
|
# Copy instruction
|
108
|
-
# @param [Array] input values (src)
|
117
|
+
# @param [Array] i input values (src)
|
109
118
|
# @return [Integer|Float] output value
|
110
119
|
def self.copy(i)
|
111
120
|
i[0]
|
@@ -113,7 +122,7 @@ module ImageFilterDsl
|
|
113
122
|
|
114
123
|
##
|
115
124
|
# Above instruction
|
116
|
-
# @param [Array] input values (a,b,trueVal,falseVal)
|
125
|
+
# @param [Array] i input values (a,b,trueVal,falseVal)
|
117
126
|
# @return [Integer|Float] output value
|
118
127
|
def self.above(i)
|
119
128
|
if(i[0]>i[1])
|
@@ -133,7 +142,7 @@ module ImageFilterDsl
|
|
133
142
|
|
134
143
|
##
|
135
144
|
# Below instruction
|
136
|
-
# @param [Array] input values (a,b,trueVal,falseVal)
|
145
|
+
# @param [Array] i input values (a,b,trueVal,falseVal)
|
137
146
|
# @return [Integer|Float] output value
|
138
147
|
def self.below(i)
|
139
148
|
if(i[0]<i[1])
|
@@ -153,7 +162,7 @@ module ImageFilterDsl
|
|
153
162
|
|
154
163
|
##
|
155
164
|
# Floor instruction
|
156
|
-
# @param [Array] input value (v)
|
165
|
+
# @param [Array] i input value (v)
|
157
166
|
# @return [Integer|Float] output value
|
158
167
|
def self.floor(i)
|
159
168
|
i[0].floor
|
@@ -161,7 +170,7 @@ module ImageFilterDsl
|
|
161
170
|
|
162
171
|
##
|
163
172
|
# Ceil instruction
|
164
|
-
# @param [Array] input value (v)
|
173
|
+
# @param [Array] i input value (v)
|
165
174
|
# @return [Integer|Float] output value
|
166
175
|
def self.ceil(i)
|
167
176
|
i[0].ceil
|
@@ -169,7 +178,7 @@ module ImageFilterDsl
|
|
169
178
|
|
170
179
|
##
|
171
180
|
# Float cast instruction
|
172
|
-
# @param [Array] input value (v)
|
181
|
+
# @param [Array] i input value (v)
|
173
182
|
# @return [Integer|Float] output value
|
174
183
|
def self.float(i)
|
175
184
|
i[0].to_f
|
@@ -177,7 +186,7 @@ module ImageFilterDsl
|
|
177
186
|
|
178
187
|
##
|
179
188
|
# Round instruction
|
180
|
-
# @param [Array] input
|
189
|
+
# @param [Array] i input values (val, decimal_places)
|
181
190
|
# @return [Integer|Float] output value
|
182
191
|
def self.round(i)
|
183
192
|
i[0].round(i[1])
|
@@ -186,8 +195,8 @@ module ImageFilterDsl
|
|
186
195
|
##
|
187
196
|
# 'Switch' instruction (basically if)
|
188
197
|
#
|
189
|
-
# switch
|
190
|
-
# @param [Array] input value (condition, true val, false val)
|
198
|
+
# switch condition (0/1/0.0/1.0), trueval, falseval]
|
199
|
+
# @param [Array] i input value (condition, true val, false val)
|
191
200
|
# @return [Integer|Float] output value
|
192
201
|
def self.switch(i)
|
193
202
|
if i[0].to_i == 1
|
@@ -199,7 +208,7 @@ module ImageFilterDsl
|
|
199
208
|
|
200
209
|
##
|
201
210
|
# Equal condition instruction
|
202
|
-
# @param [Array] input
|
211
|
+
# @param [Array] i input values (a, b)
|
203
212
|
# @return [Integer|Float] output value 1 true 0 falsew
|
204
213
|
def self.eq(i)
|
205
214
|
if i[0] == i[1]
|
@@ -211,7 +220,7 @@ module ImageFilterDsl
|
|
211
220
|
|
212
221
|
##
|
213
222
|
# Logic invert instruction
|
214
|
-
# @param [Array] input value (0 or 1)
|
223
|
+
# @param [Array] i input value (0 or 1)
|
215
224
|
# @return [Integer|Float] output value (1 if in 0, 0 if in 1)
|
216
225
|
def self.bnot(i)
|
217
226
|
if i[0].to_i == 1
|
@@ -220,6 +229,49 @@ module ImageFilterDsl
|
|
220
229
|
1
|
221
230
|
end
|
222
231
|
end
|
232
|
+
|
233
|
+
##
|
234
|
+
# Mix two values with a ratio
|
235
|
+
# @param [Array] i input values (ratio (0-1.0), a, b)
|
236
|
+
# @return [Float] output value of ((ratio*a) + ((1.0-ratio)*b))
|
237
|
+
def self.mix(i)
|
238
|
+
ratio, a, b = i
|
239
|
+
(ratio*a)+((1.0-ratio)*b)
|
240
|
+
end
|
241
|
+
|
242
|
+
##
|
243
|
+
# Random number instruction
|
244
|
+
# @param [Array] i input values (min, max)
|
245
|
+
# @return [Float] Random number between min and max
|
246
|
+
def self.rand(i)
|
247
|
+
r=Random.new
|
248
|
+
min,max = i
|
249
|
+
(-min) + (r.rand * (max + min))
|
250
|
+
end
|
251
|
+
|
252
|
+
##
|
253
|
+
# Sine function
|
254
|
+
# @param [Array] i input value to use sin on
|
255
|
+
# @return [Float] Sine of input value
|
256
|
+
def self.sin(i)
|
257
|
+
Math.sin(i[0])
|
258
|
+
end
|
259
|
+
|
260
|
+
##
|
261
|
+
# Cosine function
|
262
|
+
# @param [Array] i input value to use cos on
|
263
|
+
# @return [Float] Cosine of input value
|
264
|
+
def self.cos(i)
|
265
|
+
Math.cos(i[0])
|
266
|
+
end
|
267
|
+
|
268
|
+
##
|
269
|
+
# Tangent function
|
270
|
+
# @param [Array] i input value to use tan on
|
271
|
+
# @return [Float] Tangent of input value
|
272
|
+
def self.tan(i)
|
273
|
+
Math.tan(i[0])
|
274
|
+
end
|
223
275
|
end
|
224
276
|
end
|
225
277
|
end
|
@@ -1,9 +1,11 @@
|
|
1
1
|
##
|
2
2
|
# Image Filter DSL Library
|
3
|
-
# (c) 2018 VDTDEV/Wade H. ~ MIT License
|
4
|
-
# @author Wade H. <vdtdev@gmail.com>
|
3
|
+
# (c) 2018-2020 VDTDEV/Wade H. ~ MIT License
|
4
|
+
# @author Wade H. <vdtdev.prod@gmail.com>
|
5
5
|
module ImageFilterDsl
|
6
6
|
module Dsl
|
7
|
+
##
|
8
|
+
# Kernal module
|
7
9
|
module Kernel
|
8
10
|
##
|
9
11
|
# IFD Filter Kernel class
|
@@ -2,9 +2,10 @@ require 'chunky_png'
|
|
2
2
|
|
3
3
|
##
|
4
4
|
# Image Filter DSL Library
|
5
|
-
# (c) 2018 VDTDEV/Wade H. ~ MIT License
|
6
|
-
# @author Wade H. <vdtdev@gmail.com>
|
5
|
+
# (c) 2018-2020 VDTDEV/Wade H. ~ MIT License
|
6
|
+
# @author Wade H. <vdtdev.prod@gmail.com>
|
7
7
|
module ImageFilterDsl
|
8
|
+
# Module containing processing engine related code
|
8
9
|
module Engine
|
9
10
|
##
|
10
11
|
# Image Processor class applies Filter Kernels to images
|
@@ -12,6 +13,8 @@ module ImageFilterDsl
|
|
12
13
|
|
13
14
|
attr_accessor :kernel, :config
|
14
15
|
|
16
|
+
|
17
|
+
|
15
18
|
##
|
16
19
|
# Constructor
|
17
20
|
# @param [Dsl::Kernel::FilterKernel|String] filter_kernel FilterKernel object or path to binary kernel file
|
@@ -120,7 +123,6 @@ module ImageFilterDsl
|
|
120
123
|
b = clr.b(pixel)
|
121
124
|
a = clr.a(pixel)
|
122
125
|
|
123
|
-
|
124
126
|
inputs = Hash[*@kernel.inputs.map{|k|[k,0]}.flatten]
|
125
127
|
inputs[:x] = x if inputs.keys.include?(:x)
|
126
128
|
inputs[:y] = y if inputs.keys.include?(:y)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
##
|
2
2
|
# Image Filter DSL Library
|
3
|
-
# (c) 2018 VDTDEV/Wade H. ~ MIT License
|
4
|
-
# @author Wade H. <vdtdev@gmail.com>
|
3
|
+
# (c) 2018-2020 VDTDEV/Wade H. ~ MIT License
|
4
|
+
# @author Wade H. <vdtdev.prod@gmail.com>
|
5
5
|
module ImageFilterDsl
|
6
6
|
module Engine
|
7
7
|
##
|
@@ -10,8 +10,13 @@ module ImageFilterDsl
|
|
10
10
|
|
11
11
|
##
|
12
12
|
# Constants for format option used in read
|
13
|
+
# Dictates what is returned
|
13
14
|
module DataFormat
|
15
|
+
##
|
16
|
+
# Filter Kernal instance
|
14
17
|
KERNEL = :kernel
|
18
|
+
##
|
19
|
+
# Filter kernal record
|
15
20
|
RECORD = :record
|
16
21
|
end
|
17
22
|
|
metadata
CHANGED
@@ -1,22 +1,87 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: image_filter_dsl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wade H.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
|
11
|
+
date: 2020-02-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: chunky_png
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.3.10
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.3.10
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: bindata
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '2.4'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 2.4.3
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '2.4'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 2.4.3
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: rspec
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 3.7.0
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.7'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 3.7.0
|
70
|
+
- - "~>"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '3.7'
|
73
|
+
description: |2
|
74
|
+
Image filtering DSL including a CLI for running filters and ability
|
75
|
+
to write kernals to a binary format that will can be used to run filters
|
76
|
+
from the CLI, and potentially allow filters to be compatible with implementation
|
77
|
+
in other languages.
|
14
78
|
email: vdtdev.prod@gmail.com
|
15
79
|
executables:
|
16
80
|
- image_filter_dsl
|
17
81
|
extensions: []
|
18
82
|
extra_rdoc_files: []
|
19
83
|
files:
|
84
|
+
- README.md
|
20
85
|
- bin/image_filter_dsl
|
21
86
|
- lib/image_filter_dsl.rb
|
22
87
|
- lib/image_filter_dsl/binary/serialize.rb
|
@@ -26,11 +91,12 @@ files:
|
|
26
91
|
- lib/image_filter_dsl/dsl/kernel.rb
|
27
92
|
- lib/image_filter_dsl/engine/image_processor.rb
|
28
93
|
- lib/image_filter_dsl/engine/io.rb
|
29
|
-
homepage: https://bitbucket.org/WadeH/image_filter_dsl
|
94
|
+
homepage: https://bitbucket.org/WadeH/image_filter_dsl
|
30
95
|
licenses:
|
31
96
|
- MIT
|
32
97
|
metadata:
|
33
|
-
source_code_uri: https://bitbucket.org/WadeH/image_filter_dsl
|
98
|
+
source_code_uri: https://bitbucket.org/WadeH/image_filter_dsl
|
99
|
+
documentation_uri: https://rubydoc.info/gems/image_filter_dsl/0.0.6
|
34
100
|
post_install_message:
|
35
101
|
rdoc_options: []
|
36
102
|
require_paths:
|