Extract an RGB channel of an image
JavaScript (ES6), 29 bytes

a=&gt;n=&gt;a.map(b=&gt;b.map(c=&gt;c&amp;n))


Input is a 2D array of 24-bit integers (e.g. [[0x0000ff,0x00ff00],[0xff0000,0xffffff]]) and 16711680 for red, 65280 for green, 255 for blue. If this isn't valid, try this instead:

JavaScript (ES6), 48 bytes

a=&gt;n=&gt;a.map(b=&gt;b.map(c=&gt;c.map((d,i)=&gt;i==n?d:0)))


Input is a 3D array of color values and 0 for red, 1 for green, 2 for blue.