title: Reducing RGB color intensity in Ruby with Rmagick
body: <p>I'm translating a function made with MATLAB that reduces the color intensity from an image's sector to Ruby using Rmagick</p>
  
  <pre><code>for i=round(f/3):f 
          for j=1:round(c)
              for k=1:p
              A(i,j,k) = B(i,j,k) - a;
              end
          end
      end
  
      for i=1:round(2*f/3)
  </code></pre>
  
  <p>This reduces the color intensity of all 3 RGB matrix by some value (a). Trying to reproduce this with ruby code yielded this:</p>
  
  <pre><code>(0..imagen.columns).each do |x|
    ((2 * imagen.rows) / 3..imagen.rows).each do |y|
      imagen.pixel_color(x, y, 'pink')
    end
  end
  </code></pre>
  
  <p>I can change the lower third of my image to a set color, in this example, to pink. </p>
  
  <p>Trying to reduce each component by some value (atenuacion) with each color's method won't work, it returns the same image. </p>
  
  <pre><code>(0..imagen.columns).each do |x|
    ((2 * imagen.rows) / 3..imagen.rows).each do |y|
      pixel = imagen.pixel_color(x, y)
      pixel.red - atenuacion
      pixel.green - atenuacion
      pixel.blue - atenuacion
      imagen.pixel_color(x, y, pixel)
    end
  end
  </code></pre>
  
  <p>Any tips or suggestions are welcome, thank you in advance :D</p>