I am one of the supporting libvips, an image processing library that wraps ruby-vips.
The Tim Ruby-vips repository did not move for some time. I have a fork that works with current libvips:
https://github.com/jcupitt/ruby-vips
There is another example of ruby-vips on the vips main site, on the benchmark page. This example loads an image, visits 100 pixels from each edge, reduces it by 10%, sharpenes and saves again.
http://www.vips.ecs.soton.ac.uk/index.php?title=Speed_and_Memory_Use#ruby-vips
To set the red and blue channels to zero and just leave the green image (is that what you mean?), You can multiply R and B by zero and G by 1. A convenient operation for this is "lin", (which means "linear transformation").
http://rubyvips.holymonkey.com/classes/VIPS/Image.html#M000123
out = in.lin(a, b)
sets each pixel to
out = in * a + b
It allows you to give an array of numbers for a and b and will use one element of the array per image channel. Therefore:
#!/usr/bin/ruby require 'rubygems' require 'vips' include VIPS im = Image.new('/home/john/pics/theo.jpg') im = im.lin [0, 1, 0], [0, 0, 0] im.write('x.jpg')
To change the gamut of the image, you can try something like:
im = im.pow(0.5).lin(255 / 255 ** 0.5, 0)
Although this will be a bit slow (it will call pow () three times for each pixel), it would be much faster to do a lookup table, run pow (), and then display the image through the table:
lut = Image.identity(1) lut = lut.pow(0.5).lin(255 /255 ** 0.5, 0) im = im.maplut(lut)