// File: manikandan5[P]Image-Matching-Stitching-Warping/./CImg.h
// Function: cimg_library::CImg<double>::RGBtoHSI()
CImg<T>& RGBtoHSI() {
      if (_spectrum!=3)
        throw CImgInstanceException(_cimg_instance
                                    "RGBtoHSI(): Instance is not a RGB image.",
                                    cimg_instance);

      T *p1 = data(0,0,0,0), *p2 = data(0,0,0,1), *p3 = data(0,0,0,2);
      for (unsigned long N = (unsigned long)_width*_height*_depth; N; --N) {
        const Tfloat
          R = (Tfloat)*p1,
          G = (Tfloat)*p2,
          B = (Tfloat)*p3,
          nR = (R<0?0:(R>255?255:R))/255,
          nG = (G<0?0:(G>255?255:G))/255,
          nB = (B<0?0:(B>255?255:B))/255,
          m = cimg::min(nR,nG,nB),
          theta = (Tfloat)(std::acos(0.5f*((nR-nG)+(nR-nB))/std::sqrt(std::pow(nR-nG,2)+(nR-nB)*(nG-nB)))*180/cimg::PI),
          sum = nR + nG + nB;
        Tfloat H = 0, S = 0, I = 0;
        if (theta>0) H = (nB<=nG)?theta:360-theta;
        if (sum>0) S = 1 - 3/sum*m;
        I = sum/3;
        *(p1++) = (T)H;
        *(p2++) = (T)S;
        *(p3++) = (T)I;
      }
      return *this;
    }

// Assembly:
subq $0x128, %rsp            # imm = 0x128
movq %rdi, 0x120(%rsp)
movq 0x120(%rsp), %rax
movq %rax, 0x88(%rsp)
cmpl $0x3, 0xc(%rax)
je 0x935b5
movl $0x4008, %edi           # imm = 0x4008
callq 0x5240
movq %rax, %rcx
movq 0x88(%rsp), %rax
movq %rcx, 0x58(%rsp)
movl (%rax), %ecx
movl %ecx, 0x60(%rsp)
movl 0x4(%rax), %ecx
movl %ecx, 0x64(%rsp)
movl 0x8(%rax), %ecx
movl %ecx, 0x68(%rsp)
movl 0xc(%rax), %ecx
movl %ecx, 0x6c(%rsp)
movq 0x18(%rax), %rcx
movq %rcx, 0x70(%rsp)
movb 0x10(%rax), %dl
leaq 0x554c1(%rip), %rcx     # 0xe89d2
leaq 0x365c9(%rip), %rax     # 0xc9ae1
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, 0x78(%rsp)
callq 0x118f0
movq %rax, 0x80(%rsp)
jmp 0x93533
movl 0x6c(%rsp), %r9d
movl 0x68(%rsp), %r8d
movl 0x64(%rsp), %ecx
movl 0x60(%rsp), %edx
movq 0x58(%rsp), %rdi
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %r10
movq 0x80(%rsp), %r11
movq %rsp, %rax
movq %r11, 0x10(%rax)
movq %r10, 0x8(%rax)
movq %rsi, (%rax)
leaq 0x57f49(%rip), %rsi     # 0xeb4ba
xorl %eax, %eax
callq 0x11fd0
jmp 0x9357a
movq 0x58(%rsp), %rdi
leaq 0x6c5c2(%rip), %rsi     # 0xffb48
leaq -0x8137d(%rip), %rdx    # 0x12210
callq 0x5920
movq 0x58(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
callq 0x53a0
jmp 0x93a83
movq 0x88(%rsp), %rdi
xorl %r8d, %r8d
movl %r8d, %esi
movl %r8d, %edx
movl %r8d, %ecx
callq 0x5e180
movq 0x88(%rsp), %rdi
movq %rax, 0x108(%rsp)
xorl %ecx, %ecx
movl $0x1, %r8d
movl %ecx, %esi
movl %ecx, %edx
callq 0x5e180
movq 0x88(%rsp), %rdi
movq %rax, 0x100(%rsp)
xorl %ecx, %ecx
movl $0x2, %r8d
movl %ecx, %esi
movl %ecx, %edx
callq 0x5e180
movq 0x88(%rsp), %rcx
movq %rax, 0xf8(%rsp)
movl (%rcx), %eax
movl 0x4(%rcx), %edx
imulq %rdx, %rax
movl 0x8(%rcx), %ecx
imulq %rcx, %rax
movq %rax, 0xf0(%rsp)
cmpq $0x0, 0xf0(%rsp)
je 0x93a73
movq 0x108(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0xe8(%rsp)
movq 0x100(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0xe0(%rsp)
movq 0xf8(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0xd8(%rsp)
xorps %xmm0, %xmm0
ucomisd 0xe8(%rsp), %xmm0
jbe 0x9369f
xorps %xmm0, %xmm0
movsd %xmm0, 0x50(%rsp)
jmp 0x936e1
movsd 0xe8(%rsp), %xmm0
movsd 0x34958(%rip), %xmm1    # 0xc8008
ucomisd %xmm1, %xmm0
jbe 0x936c6
movsd 0x3494a(%rip), %xmm0    # 0xc8008
movsd %xmm0, 0x48(%rsp)
jmp 0x936d5
movsd 0xe8(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0x50(%rsp), %xmm0
movsd 0x34919(%rip), %xmm1    # 0xc8008
divsd %xmm1, %xmm0
movsd %xmm0, 0xd0(%rsp)
xorps %xmm0, %xmm0
ucomisd 0xe0(%rsp), %xmm0
jbe 0x93715
xorps %xmm0, %xmm0
movsd %xmm0, 0x40(%rsp)
jmp 0x93757
movsd 0xe0(%rsp), %xmm0
movsd 0x348e2(%rip), %xmm1    # 0xc8008
ucomisd %xmm1, %xmm0
jbe 0x9373c
movsd 0x348d4(%rip), %xmm0    # 0xc8008
movsd %xmm0, 0x38(%rsp)
jmp 0x9374b
movsd 0xe0(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
movsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0x40(%rsp), %xmm0
movsd 0x348a3(%rip), %xmm1    # 0xc8008
divsd %xmm1, %xmm0
movsd %xmm0, 0xc8(%rsp)
xorps %xmm0, %xmm0
ucomisd 0xd8(%rsp), %xmm0
jbe 0x9378b
xorps %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
jmp 0x937cd
movsd 0xd8(%rsp), %xmm0
movsd 0x3486c(%rip), %xmm1    # 0xc8008
ucomisd %xmm1, %xmm0
jbe 0x937b2
movsd 0x3485e(%rip), %xmm0    # 0xc8008
movsd %xmm0, 0x28(%rsp)
jmp 0x937c1
movsd 0xd8(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x30(%rsp), %xmm0
movsd 0x3482d(%rip), %xmm1    # 0xc8008
divsd %xmm1, %xmm0
movsd %xmm0, 0xc0(%rsp)
leaq 0xd0(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x93a90
movsd %xmm0, 0xb8(%rsp)
movsd 0xd0(%rsp), %xmm1
subsd 0xc8(%rsp), %xmm1
movsd 0xd0(%rsp), %xmm0
subsd 0xc0(%rsp), %xmm0
addsd %xmm0, %xmm1
movsd 0x3480a(%rip), %xmm0    # 0xc8048
mulsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0xd0(%rsp), %xmm0
subsd 0xc8(%rsp), %xmm0
movl $0x2, %edi
callq 0x93ad0
movaps %xmm0, %xmm1
movsd 0xd0(%rsp), %xmm0
subsd 0xc0(%rsp), %xmm0
movsd 0xc8(%rsp), %xmm2
subsd 0xc0(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x5410
movaps %xmm0, %xmm1
movsd 0x20(%rsp), %xmm0
divsd %xmm1, %xmm0
callq 0x54f0
movsd 0x347c6(%rip), %xmm1    # 0xc8078
mulsd %xmm1, %xmm0
movsd 0x347b2(%rip), %xmm1    # 0xc8070
divsd %xmm1, %xmm0
movsd %xmm0, 0xb0(%rsp)
movsd 0xd0(%rsp), %xmm0
addsd 0xc8(%rsp), %xmm0
addsd 0xc0(%rsp), %xmm0
movsd %xmm0, 0xa8(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0xa0(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x98(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x90(%rsp)
movsd 0xb0(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x93974
movsd 0xc0(%rsp), %xmm1
movsd 0xc8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x9394e
movsd 0xb0(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
jmp 0x93965
movsd 0x3472a(%rip), %xmm0    # 0xc8080
subsd 0xb0(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0xa0(%rsp)
movsd 0xa8(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x939d0
movsd 0x346c2(%rip), %xmm0    # 0xc8050
divsd 0xa8(%rsp), %xmm0
movsd 0xb8(%rsp), %xmm1
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm1, %xmm0
movsd 0x34655(%rip), %xmm1    # 0xc8018
addsd %xmm1, %xmm0
movsd %xmm0, 0x98(%rsp)
movsd 0xa8(%rsp), %xmm0
movsd 0x3466f(%rip), %xmm1    # 0xc8050
divsd %xmm1, %xmm0
movsd %xmm0, 0x90(%rsp)
movsd 0xa0(%rsp), %xmm0
movq 0x108(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x108(%rsp)
movsd %xmm0, (%rax)
movsd 0x98(%rsp), %xmm0
movq 0x100(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x100(%rsp)
movsd %xmm0, (%rax)
movsd 0x90(%rsp), %xmm0
movq 0xf8(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0xf8(%rsp)
movsd %xmm0, (%rax)
movq 0xf0(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0xf0(%rsp)
jmp 0x93638
movq 0x88(%rsp), %rax
addq $0x128, %rsp            # imm = 0x128
retq
movq 0x118(%rsp), %rdi
callq 0x5970