// File: tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelImage.cpp
// Function: gaps::R3SurfelImage::ColorChannels() const
R2Image R3SurfelImage::
ColorChannels(void) const
{
  // Allocate color image for result
  R2Image color_image;

  // Get RGB channels
  const R2Grid *red_channel = RedChannel();
  const R2Grid *green_channel = GreenChannel();
  const R2Grid *blue_channel = BlueChannel();
  if (red_channel && green_channel && blue_channel) {
    // Fill in RGB for each pixel
    color_image = R2Image(ImageWidth(), ImageHeight(), 3);
    for (int iy = 0; iy < ImageHeight(); iy++) {
      for (int ix = 0; ix < ImageWidth(); ix++) {
        RNScalar red = red_channel->GridValue(ix, iy);
        RNScalar green = green_channel->GridValue(ix, iy);
        RNScalar blue = blue_channel->GridValue(ix, iy);
        RNRgb color(red, green, blue);
        color_image.SetPixelRGB(ix, iy, color);
      }
    }
  }

  // Return color image
  return color_image;
}

// Assembly:
subq $0xf8, %rsp
movq %rdi, 0x48(%rsp)
movq %rdi, %rax
movq %rax, 0x50(%rsp)
movq %rdi, 0xf0(%rsp)
movq %rsi, 0xe8(%rsp)
movq 0xe8(%rsp), %rax
movq %rax, 0x58(%rsp)
movb $0x0, 0xe7(%rsp)
callq 0x1352f0
movq 0x58(%rsp), %rdi
callq 0x6b890
movq %rax, 0x60(%rsp)
jmp 0x678bf
movq 0x58(%rsp), %rdi
movq 0x60(%rsp), %rax
movq %rax, 0xd8(%rsp)
callq 0x6b8b0
movq %rax, 0x40(%rsp)
jmp 0x678dd
movq 0x58(%rsp), %rdi
movq 0x40(%rsp), %rax
movq %rax, 0xc0(%rsp)
callq 0x6b8d0
movq %rax, 0x38(%rsp)
jmp 0x678fb
movq 0x38(%rsp), %rax
movq %rax, 0xb8(%rsp)
cmpq $0x0, 0xd8(%rsp)
je 0x67b45
cmpq $0x0, 0xc0(%rsp)
je 0x67b45
cmpq $0x0, 0xb8(%rsp)
je 0x67b45
movq 0x58(%rsp), %rdi
callq 0x308f0
movl %eax, 0x34(%rsp)
jmp 0x67945
movq 0x58(%rsp), %rdi
callq 0x30920
movl %eax, 0x30(%rsp)
jmp 0x67955
movl 0x30(%rsp), %edx
movl 0x34(%rsp), %esi
leaq 0xa0(%rsp), %rdi
movl $0x3, %ecx
callq 0x135820
jmp 0x67971
movq 0x48(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x135ef0
jmp 0x67985
leaq 0xa0(%rsp), %rdi
callq 0x135d40
movl $0x0, 0x9c(%rsp)
movq 0x58(%rsp), %rdi
movl 0x9c(%rsp), %eax
movl %eax, 0x28(%rsp)
callq 0x30920
movl %eax, 0x2c(%rsp)
jmp 0x679b8
movl 0x28(%rsp), %eax
movl 0x2c(%rsp), %ecx
cmpl %ecx, %eax
jge 0x67b43
movl $0x0, 0x98(%rsp)
movq 0x58(%rsp), %rdi
movl 0x98(%rsp), %eax
movl %eax, 0x20(%rsp)
callq 0x308f0
movl %eax, 0x24(%rsp)
jmp 0x679ee
movl 0x20(%rsp), %eax
movl 0x24(%rsp), %ecx
cmpl %ecx, %eax
jge 0x67b2b
movq 0xd8(%rsp), %rdi
movl 0x98(%rsp), %esi
movl 0x9c(%rsp), %edx
callq 0x45350
movsd %xmm0, 0x18(%rsp)
jmp 0x67a21
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x90(%rsp)
movq 0xc0(%rsp), %rdi
movl 0x98(%rsp), %esi
movl 0x9c(%rsp), %edx
callq 0x45350
movsd %xmm0, 0x10(%rsp)
jmp 0x67a53
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x88(%rsp)
movq 0xb8(%rsp), %rdi
movl 0x98(%rsp), %esi
movl 0x9c(%rsp), %edx
callq 0x45350
movsd %xmm0, 0x8(%rsp)
jmp 0x67a85
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x80(%rsp)
movsd 0x90(%rsp), %xmm0
movsd 0x88(%rsp), %xmm1
movsd 0x80(%rsp), %xmm2
leaq 0x68(%rsp), %rdi
callq 0x141cf0
jmp 0x67abb
movq 0x48(%rsp), %rdi
movl 0x98(%rsp), %esi
movl 0x9c(%rsp), %edx
leaq 0x68(%rsp), %rcx
callq 0x136070
jmp 0x67ada
jmp 0x67adc
movl 0x98(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x98(%rsp)
jmp 0x679d3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
jmp 0x67b6e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x135d40
jmp 0x67b6e
jmp 0x67b2d
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0x6799d
jmp 0x67b45
movb $0x1, 0xe7(%rsp)
testb $0x1, 0xe7(%rsp)
jne 0x67b61
movq 0x48(%rsp), %rdi
callq 0x135d40
movq 0x50(%rsp), %rax
addq $0xf8, %rsp
retq
movq 0x48(%rsp), %rdi
callq 0x135d40
movq 0xd0(%rsp), %rdi
callq 0x13970
nopw %cs:(%rax,%rax)