// File: kebwi[P]Trifid/src/ImageProcs.cpp
// Function: labImgToRgbImg(double, Image3ChnlReal const&, Image3ChnlReal&)
void labImgToRgbImg(Float_t maxVal, const Image3ChnlReal &labImg, Image3ChnlReal &rgbImg)
{
	rgbImg.resize(labImg.width(), labImg.height());
	
	Float_t r, g, b;
	Float_t x, y, z;
	Float_t l, a, b2;
	int totalPixels = labImg.totalPixels();
	for (int i = 0; i < totalPixels; i++)
	{
		l = (*labImg[0])[i];
		a = (*labImg[1])[i];
		b2 = (*labImg[2])[i];
		
		cielab2xyz(l, a, b2, x, y, z);
		xyz2rgb(x, y, z, r, g, b);
		
		(*rgbImg[0])[i] = r * maxVal;
		(*rgbImg[1])[i] = g * maxVal;
		(*rgbImg[2])[i] = b * maxVal;
	}
	
	rgbImg.setFilename(labImg.filename());
	rgbImg.appendFilename("_rgb");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movsd %xmm0, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x10(%rbp), %rdi
callq 0xedd0
movl %eax, -0x98(%rbp)
movq -0x10(%rbp), %rdi
callq 0xedf0
movq -0xa0(%rbp), %rdi
movl -0x98(%rbp), %esi
movl %eax, %edx
movq (%rdi), %rax
callq *0x28(%rax)
movq -0x10(%rbp), %rdi
callq 0xf200
movl %eax, -0x64(%rbp)
movl $0x0, -0x68(%rbp)
movl -0x68(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0x1fa62
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x25920
movq %rax, %rdi
movl -0x68(%rbp), %esi
callq 0x25950
movsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x25920
movq %rax, %rdi
movl -0x68(%rbp), %esi
callq 0x25950
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x10(%rbp), %rdi
movl $0x2, %esi
callq 0x25920
movq %rax, %rdi
movl -0x68(%rbp), %esi
callq 0x25950
movsd (%rax), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x50(%rbp), %xmm0
movsd -0x58(%rbp), %xmm1
movsd -0x60(%rbp), %xmm2
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x1e490
movsd -0x38(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
movsd -0x48(%rbp), %xmm2
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
leaq -0x30(%rbp), %rdx
callq 0x1e100
movsd -0x20(%rbp), %xmm0
mulsd -0x8(%rbp), %xmm0
movsd %xmm0, -0xb8(%rbp)
movq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0xef40
movq %rax, %rdi
movl -0x68(%rbp), %esi
callq 0xef70
movsd -0xb8(%rbp), %xmm0
movsd %xmm0, (%rax)
movsd -0x28(%rbp), %xmm0
mulsd -0x8(%rbp), %xmm0
movsd %xmm0, -0xb0(%rbp)
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0xef40
movq %rax, %rdi
movl -0x68(%rbp), %esi
callq 0xef70
movsd -0xb0(%rbp), %xmm0
movsd %xmm0, (%rax)
movsd -0x30(%rbp), %xmm0
mulsd -0x8(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movq -0x18(%rbp), %rdi
movl $0x2, %esi
callq 0xef40
movq %rax, %rdi
movl -0x68(%rbp), %esi
callq 0xef70
movsd -0xa8(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x1f903
movq -0x18(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x88(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0xf090
movq -0xc8(%rbp), %rdi
movq -0xc0(%rbp), %rsi
callq 0x154b0
jmp 0x1fa99
leaq -0x88(%rbp), %rdi
callq 0x46c8
movq -0x18(%rbp), %rdi
leaq 0x2a0c0(%rip), %rsi     # 0x49b70
callq 0xf220
addq $0xd0, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x46c8
movq -0x90(%rbp), %rdi
callq 0x4620
nopl (%rax,%rax)