image_filter_dsl 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0074cce853619a9d03bce9fc25a7de626137cc5b6355e7f9cf5d80668facf28c
4
- data.tar.gz: aeae830c13a2d99060c6f41ec62794c9edf7647d110b44ecfdbcb0db37d1a968
3
+ metadata.gz: c683878731b0e51f247aff3462f53272a04c13e4c31fbbf1daa14e9ec606f235
4
+ data.tar.gz: 606bc6208d106f867700b051bb73c917fc55d9985e8df0071e882a90e644f4db
5
5
  SHA512:
6
- metadata.gz: 8f124907e599e65a9ab8f9f11f4b7cc66eb68b3eaa66da8fecd9dd2b7a9103ec4c1f2a3494d86e0d0a605f166e191d164b51e2fe73e4b6311eb96aefa81bc765
7
- data.tar.gz: 8966b080bd969cc601cc9bb9652b347d65feebb129c15b20d249bf5f2bff71f3a7d2d293411762738eec2303e93ee88316ee240825a5c4f6839604d330a47a28
6
+ metadata.gz: 88a3935892903034fdef3c0d1e1065d3886a5b6d636b6f46d693cb53fc2a7409cb151bda74ae15b83c39f7dd850a126d83c737da55204262a1592000f9294d55
7
+ data.tar.gz: 43cbfb2c910938575dbc1a83835e454d0ff1f61000a8f1a8d93247a10fb0b6fa6e2f9288f86a49e4f338a59264e498f513d316957aa693f8b6e543f673cf69db
data/README.md ADDED
@@ -0,0 +1,59 @@
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
+ ## Features
8
+
9
+ - DSL with customizable input and output variables, and a set of basic instructions
10
+ - IO with serialization so Kernels can be written to binary files and loaded from binary files
11
+ - Image Processor that generates image file by applying Filter Kernel to every pixel of input image (supports multi-threading)
12
+
13
+ ### Sample
14
+
15
+ Define filter
16
+
17
+ ```ruby
18
+ swizzle = Filter.define [:r,:g,:b], [:r,:g,:b] do
19
+ copy [:g], :t # copy green to temp
20
+ copy [:r], :g # copy red to green
21
+ copy [:b], :r # copy blue to red
22
+ copy [:t], :b # copy temp (original green) to blue
23
+ end
24
+ ```
25
+
26
+ Optionally write filter kernal to binary file on disk
27
+
28
+ ```ruby
29
+ ImageFilterDsl::Engine::IO.write("./swizzle.ifdkk", swizzle)
30
+ ```
31
+
32
+ Use filter kernal to process image
33
+
34
+ ```ruby
35
+ # From binary kernal file
36
+ processor = ImageFilterDsl::Engine::ImageProcessor.new('./swizzle.ifdk')
37
+ # OR from filter object
38
+ processor = ImageFilterDsl::Engine::ImageProcessor.new(swizzle)
39
+ # or use aliases in main module
40
+ processor = ImageFilterDsl.image_processor(swizzle)
41
+
42
+ # Process image and store output
43
+ processor.process_image('./my_source.png', './my_output.png')
44
+ ```
45
+
46
+ - See `./sample_filters/samples.rb`
47
+ - See Also: [image_filter_dsl_samples](https://bitbucket.org/WadeH/image_filter_dsl_samples/src/master/) for samples
48
+
49
+ ## Gem
50
+
51
+ Either
52
+ - Build into a gem using included `gemspec` file; includes CLI functionality
53
+ - Install using gem with `gem install image_filter_dsl`
54
+
55
+
56
+ ## License
57
+
58
+ (c) 2018-2020, Wade H. (vdtdev.prod@gmail.com). All Rights Reserved.
59
+ Released under MIT license
@@ -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] &block Filter instructions body
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,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
  ##
@@ -40,7 +40,7 @@ module ImageFilterDsl
40
40
 
41
41
  ##
42
42
  # Add instruction
43
- # @param [Array] input values
43
+ # @param [Array] i input values
44
44
  # @return [Integer|Float] output value
45
45
  def self.add(i)
46
46
  i.sum
@@ -48,7 +48,7 @@ module ImageFilterDsl
48
48
 
49
49
  ##
50
50
  # Multiply instruction
51
- # @param [Array] input values
51
+ # @param [Array] i input values
52
52
  # @return [Integer|Float] output value
53
53
  def self.mult(i)
54
54
  v=1;
@@ -58,14 +58,14 @@ module ImageFilterDsl
58
58
 
59
59
  ##
60
60
  # Multiply instruction
61
- # @param [Array] input values
61
+ # @param [Array] i input values
62
62
  # @return [Integer|Float] output value
63
63
  def self.div(i)
64
64
  i[0]/i[1]
65
65
  end
66
66
  ##
67
67
  # Calculate modulo
68
- # @param [Array] input values
68
+ # @param [Array] i input values
69
69
  # @return [Integer|] output value
70
70
  def self.mod(i)
71
71
  i[0] % i[1]
@@ -73,7 +73,7 @@ module ImageFilterDsl
73
73
 
74
74
  ##
75
75
  # Absolute value
76
- # @param [Array] input value
76
+ # @param [Array] i input value
77
77
  # @return [Integer|Float] output value
78
78
  def self.abs(i)
79
79
  i[0].abs
@@ -81,7 +81,7 @@ module ImageFilterDsl
81
81
 
82
82
  ##
83
83
  # Minimum instruction
84
- # @param [Array] input values
84
+ # @param [Array] i input values
85
85
  # @return [Integer|Float] output value
86
86
  def self.min(i)
87
87
  i.min
@@ -89,7 +89,7 @@ module ImageFilterDsl
89
89
 
90
90
  ##
91
91
  # Maximum instruction
92
- # @param [Array] input values
92
+ # @param [Array] i input values
93
93
  # @return [Integer|Float] output value
94
94
  def self.max(i)
95
95
  i.max
@@ -97,7 +97,7 @@ module ImageFilterDsl
97
97
 
98
98
  ##
99
99
  # Average instruction
100
- # @param [Array] input values
100
+ # @param [Array] i input values
101
101
  # @return [Integer|Float] output value
102
102
  def self.avg(i)
103
103
  i.sum / (1.0 * i.length)
@@ -105,7 +105,7 @@ module ImageFilterDsl
105
105
 
106
106
  ##
107
107
  # Copy instruction
108
- # @param [Array] input values (src)
108
+ # @param [Array] i input values (src)
109
109
  # @return [Integer|Float] output value
110
110
  def self.copy(i)
111
111
  i[0]
@@ -113,7 +113,7 @@ module ImageFilterDsl
113
113
 
114
114
  ##
115
115
  # Above instruction
116
- # @param [Array] input values (a,b,trueVal,falseVal)
116
+ # @param [Array] i input values (a,b,trueVal,falseVal)
117
117
  # @return [Integer|Float] output value
118
118
  def self.above(i)
119
119
  if(i[0]>i[1])
@@ -133,7 +133,7 @@ module ImageFilterDsl
133
133
 
134
134
  ##
135
135
  # Below instruction
136
- # @param [Array] input values (a,b,trueVal,falseVal)
136
+ # @param [Array] i input values (a,b,trueVal,falseVal)
137
137
  # @return [Integer|Float] output value
138
138
  def self.below(i)
139
139
  if(i[0]<i[1])
@@ -153,7 +153,7 @@ module ImageFilterDsl
153
153
 
154
154
  ##
155
155
  # Floor instruction
156
- # @param [Array] input value (v)
156
+ # @param [Array] i input value (v)
157
157
  # @return [Integer|Float] output value
158
158
  def self.floor(i)
159
159
  i[0].floor
@@ -161,7 +161,7 @@ module ImageFilterDsl
161
161
 
162
162
  ##
163
163
  # Ceil instruction
164
- # @param [Array] input value (v)
164
+ # @param [Array] i input value (v)
165
165
  # @return [Integer|Float] output value
166
166
  def self.ceil(i)
167
167
  i[0].ceil
@@ -169,7 +169,7 @@ module ImageFilterDsl
169
169
 
170
170
  ##
171
171
  # Float cast instruction
172
- # @param [Array] input value (v)
172
+ # @param [Array] i input value (v)
173
173
  # @return [Integer|Float] output value
174
174
  def self.float(i)
175
175
  i[0].to_f
@@ -177,7 +177,7 @@ module ImageFilterDsl
177
177
 
178
178
  ##
179
179
  # Round instruction
180
- # @param [Array] input value (val, decimal_places)
180
+ # @param [Array] i input values (val, decimal_places)
181
181
  # @return [Integer|Float] output value
182
182
  def self.round(i)
183
183
  i[0].round(i[1])
@@ -187,7 +187,7 @@ module ImageFilterDsl
187
187
  # 'Switch' instruction (basically if)
188
188
  #
189
189
  # switch [condition (0/1/0.0/1.0), trueval, falseval]
190
- # @param [Array] input value (condition, true val, false val)
190
+ # @param [Array] i input value (condition, true val, false val)
191
191
  # @return [Integer|Float] output value
192
192
  def self.switch(i)
193
193
  if i[0].to_i == 1
@@ -199,7 +199,7 @@ module ImageFilterDsl
199
199
 
200
200
  ##
201
201
  # Equal condition instruction
202
- # @param [Array] input value (a, b)
202
+ # @param [Array] i input values (a, b)
203
203
  # @return [Integer|Float] output value 1 true 0 falsew
204
204
  def self.eq(i)
205
205
  if i[0] == i[1]
@@ -211,7 +211,7 @@ module ImageFilterDsl
211
211
 
212
212
  ##
213
213
  # Logic invert instruction
214
- # @param [Array] input value (0 or 1)
214
+ # @param [Array] i input value (0 or 1)
215
215
  # @return [Integer|Float] output value (1 if in 0, 0 if in 1)
216
216
  def self.bnot(i)
217
217
  if i[0].to_i == 1
@@ -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
@@ -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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: image_filter_dsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wade H.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-12 00:00:00.000000000 Z
11
+ date: 2020-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chunky_png
@@ -70,13 +70,18 @@ dependencies:
70
70
  - - "~>"
71
71
  - !ruby/object:Gem::Version
72
72
  version: '3.7'
73
- description: Image Filter DSL with processing
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.
74
78
  email: vdtdev.prod@gmail.com
75
79
  executables:
76
80
  - image_filter_dsl
77
81
  extensions: []
78
82
  extra_rdoc_files: []
79
83
  files:
84
+ - README.md
80
85
  - bin/image_filter_dsl
81
86
  - lib/image_filter_dsl.rb
82
87
  - lib/image_filter_dsl/binary/serialize.rb
@@ -86,11 +91,11 @@ files:
86
91
  - lib/image_filter_dsl/dsl/kernel.rb
87
92
  - lib/image_filter_dsl/engine/image_processor.rb
88
93
  - lib/image_filter_dsl/engine/io.rb
89
- homepage: https://bitbucket.org/WadeH/image_filter_dsl/src
94
+ homepage: https://bitbucket.org/WadeH/image_filter_dsl
90
95
  licenses:
91
96
  - MIT
92
97
  metadata:
93
- source_code_uri: https://bitbucket.org/WadeH/image_filter_dsl/src
98
+ source_code_uri: https://bitbucket.org/WadeH/image_filter_dsl
94
99
  post_install_message:
95
100
  rdoc_options: []
96
101
  require_paths: