Tim Felgentreff uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-tfel.310.mcz ==================== Summary ==================== Name: Graphics-tfel.310 Author: tfel Time: 17 April 2015, 2:37:38.42 pm UUID: dcfe87bc-46ca-c04e-b99b-5a711f8a8c9e Ancestors: Graphics-tk.309 add convolution to forms and some common kernels for blurring, sharpening and so on =============== Diff against Graphics-tk.309 =============== Item was added: + ----- Method: Form>>approxGaussianBlur (in category 'processing') ----- + approxGaussianBlur + + ^ self processUsingKernel: (Matrix rows: 3 columns: 3 contents: #( + 1 2 1 + 2 4 2 + 1 2 1 + ) * 0.0625)! Item was added: + ----- Method: Form>>edgeDetect (in category 'processing') ----- + edgeDetect + + ^ self processUsingKernel: (Matrix rows: 3 columns: 3 contents: #( + -1 -1 -1 + -1 8 -1 + -1 -1 -1 + ))! Item was added: + ----- Method: Form>>emboss (in category 'processing') ----- + emboss + + ^ self processUsingKernel: (Matrix rows: 3 columns: 3 contents: #( + -2 -1 0 + -1 1 1 + 0 1 2 + ))! Item was added: + ----- Method: Form>>processUsingKernel: (in category 'processing') ----- + processUsingKernel: filter + + ^ self processUsingKernel: filter factor: 1.0 bias: 0.0! Item was added: + ----- Method: Form>>processUsingKernel:factor:bias: (in category 'processing') ----- + processUsingKernel: filter factor: factor bias: bias + | image result | + + image := self. + result := Form extent: image extent depth: image depth. + + 0 to: image height - 1 do: [:y | + 0 to: image width - 1 do: [:x | + | r g b | + r := g := b := 0.0. + + 0 to: filter rowCount - 1 do: [:filterY | + 0 to: filter columnCount - 1 do: [:filterX | + | imageX imageY | + imageX := (x - (filter columnCount // 2) + filterX + image width) \\ + image width. + imageY := (y - (filter rowCount // 2) + filterY + image height) \\ + image height. + r := r + ((image colorAt: imageX@imageY) red * + (filter at: filterY + 1 at: filterX + 1)). + g := g + ((image colorAt: imageX@imageY) green * + (filter at: filterY + 1 at: filterX + 1)). + b := b + ((image colorAt: imageX@imageY) blue * + (filter at: filterY + 1 at: filterX + 1))]]. + + result colorAt: x@y put: (Color + r: ((factor * r + bias) min: 1.0 max: 0.0) + g: ((factor * g + bias) min: 1.0 max: 0.0) + b: ((factor * b + bias) min: 1.0 max: 0.0))]]. + ^ result + ! Item was added: + ----- Method: Form>>sharpen (in category 'processing') ----- + sharpen + + ^ self processUsingKernel: (Matrix rows: 3 columns: 3 contents: #( + 0 -1 0 + -1 5 -1 + 0 -1 0 + ))! |
Cool Karl On Fri, Apr 17, 2015 at 2:37 PM, <[hidden email]> wrote: Tim Felgentreff uploaded a new version of Graphics to project The Trunk: |
In reply to this post by commits-2
Wouldn't it be better to use FFT?
Levente On Fri, 17 Apr 2015, [hidden email] wrote: > Tim Felgentreff uploaded a new version of Graphics to project The Trunk: > http://source.squeak.org/trunk/Graphics-tfel.310.mcz > > ==================== Summary ==================== > > Name: Graphics-tfel.310 > Author: tfel > Time: 17 April 2015, 2:37:38.42 pm > UUID: dcfe87bc-46ca-c04e-b99b-5a711f8a8c9e > Ancestors: Graphics-tk.309 > > add convolution to forms and some common kernels for blurring, sharpening and so on > > =============== Diff against Graphics-tk.309 =============== > > Item was added: > + ----- Method: Form>>approxGaussianBlur (in category 'processing') ----- > + approxGaussianBlur > + > + ^ self processUsingKernel: (Matrix rows: 3 columns: 3 contents: #( > + 1 2 1 > + 2 4 2 > + 1 2 1 > + ) * 0.0625)! > > Item was added: > + ----- Method: Form>>edgeDetect (in category 'processing') ----- > + edgeDetect > + > + ^ self processUsingKernel: (Matrix rows: 3 columns: 3 contents: #( > + -1 -1 -1 > + -1 8 -1 > + -1 -1 -1 > + ))! > > Item was added: > + ----- Method: Form>>emboss (in category 'processing') ----- > + emboss > + > + ^ self processUsingKernel: (Matrix rows: 3 columns: 3 contents: #( > + -2 -1 0 > + -1 1 1 > + 0 1 2 > + ))! > > Item was added: > + ----- Method: Form>>processUsingKernel: (in category 'processing') ----- > + processUsingKernel: filter > + > + ^ self processUsingKernel: filter factor: 1.0 bias: 0.0! > > Item was added: > + ----- Method: Form>>processUsingKernel:factor:bias: (in category 'processing') ----- > + processUsingKernel: filter factor: factor bias: bias > + | image result | > + > + image := self. > + result := Form extent: image extent depth: image depth. > + > + 0 to: image height - 1 do: [:y | > + 0 to: image width - 1 do: [:x | > + | r g b | > + r := g := b := 0.0. > + > + 0 to: filter rowCount - 1 do: [:filterY | > + 0 to: filter columnCount - 1 do: [:filterX | > + | imageX imageY | > + imageX := (x - (filter columnCount // 2) + filterX + image width) \\ > + image width. > + imageY := (y - (filter rowCount // 2) + filterY + image height) \\ > + image height. > + r := r + ((image colorAt: imageX@imageY) red * > + (filter at: filterY + 1 at: filterX + 1)). > + g := g + ((image colorAt: imageX@imageY) green * > + (filter at: filterY + 1 at: filterX + 1)). > + b := b + ((image colorAt: imageX@imageY) blue * > + (filter at: filterY + 1 at: filterX + 1))]]. > + > + result colorAt: x@y put: (Color > + r: ((factor * r + bias) min: 1.0 max: 0.0) > + g: ((factor * g + bias) min: 1.0 max: 0.0) > + b: ((factor * b + bias) min: 1.0 max: 0.0))]]. > + ^ result > + ! > > Item was added: > + ----- Method: Form>>sharpen (in category 'processing') ----- > + sharpen > + > + ^ self processUsingKernel: (Matrix rows: 3 columns: 3 contents: #( > + 0 -1 0 > + -1 5 -1 > + 0 -1 0 > + ))! > > > |
Free forum by Nabble | Edit this page |