Sha256: 637124afc51b1782b189412da487d169673dc1d59192fbf50545580ace0c77eb

Contents?: true

Size: 707 Bytes

Versions: 13

Compression:

Stored size: 707 Bytes

Contents

#!/usr/bin/env ruby -w
require 'rmagick'

# Demonstrate the Image#reduce_noise method

img = Magick::Image.read('images/Flower_Hat.jpg').first
img = img.add_noise(Magick::UniformNoise)

eimg = img.reduce_noise(0)

# Zoom in so we can see the change
img.resize!(3)
eimg.resize!(3)

# Make a before-and-after composite
eimg.crop!(eimg.columns/2, 0, eimg.columns/2, eimg.rows)
img = img.composite(eimg, Magick::EastGravity, Magick::OverCompositeOp)

# Draw a black line between the before and after parts.
line = Magick::Draw.new
line.line(img.columns/2, 0, img.columns/2, img.rows)
line.draw(img)

# Crop everything but the face.
img.crop!(Magick::CenterGravity, 250, 200)

img.write('reduce_noise.jpg')
exit

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
rmagick-windows-2.16.5 doc/ex/reduce_noise.rb
rmagick-windows-2.16.4 doc/ex/reduce_noise.rb
rmagick-windows-2.16.3 doc/ex/reduce_noise.rb
rmagick-windows-2.16.2 doc/ex/reduce_noise.rb
rmagick-windows-2.16.1 doc/ex/reduce_noise.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/rmagick-2.16.0/doc/ex/reduce_noise.rb
rmagick-2.16.0 doc/ex/reduce_noise.rb
rmagick-2.15.4 doc/ex/reduce_noise.rb
rmagick-2.15.3 doc/ex/reduce_noise.rb
rmagick-2.15.2 doc/ex/reduce_noise.rb
rmagick-2.15.1 doc/ex/reduce_noise.rb
rmagick-2.15.0 doc/ex/reduce_noise.rb
rmagick-2.14.0 doc/ex/reduce_noise.rb