// File: /workspace/github_cpp_makefile_star2_O2/kebwi[P]Trifid/src/ImageProcs.cpp
// Function: denoiseRGBImage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void denoiseRGBImage(string filename, string manualShrinkageThresholdStr)
{
	cout << "Denoising color image..." << endl;
	
	//Open the image
	Image3ChnlReal rgbImage;
	rgbImage.readFile(filename);
	
	//Construct a steerable pyramid of the image
	SteerablePyramid steerPyr[3];
	for (int c = 0; c < 3; c++)
		steerPyr[c].DoFullWaveletAnalysis(rgbImage[c]->img(), rgbImage[c]->width(), rgbImage[c]->height(), true);
	
	if (gGenerateIntermediateImages)
	{
		for (int c = 0; c < 3; c++)
		{
			string s = rgbImage.filename();
			if (c == 0)
				s += "_R";
			else if (c == 1)
				s += "_G";
			else s += "_B";
			steerPyr[c].GeneratePGMimages(s.c_str());
		}
	}
	
	int numLevels = steerPyr[0].NumLevels();
	cout << "Steerable pyramid will be built with " << numLevels << " levels" << endl;
	if (gManualShrinkageThresholds[0].size() != numLevels + 1)
		for (int c = 0; c < 3; c++)
			gManualShrinkageThresholds[c].resize(numLevels + 1);
	cout << "Thresholds:" << endl;
	for (int c = 0; c < 3; c++)
	{
		if (c == 0)
			cout << "  Red:" << endl;
		else if (c == 1)
			cout << "  Green:" << endl;
		else cout << "  Blue:" << endl;
		
		cout << "    H:  " << setw(10) << gManualShrinkageThresholds[c][0] << endl;
		cout << "    B:  ";
		for (int i = 1; i < gManualShrinkageThresholds[c].size(); i++)
			cout << setw(10) << gManualShrinkageThresholds[c][i];
		cout << endl;
	}
	cout << endl;
	
	//Shrink the coefficients
	for (int c = 0; c < 3; c++)
		steerPyr[c].SoftThreshold(gManualShrinkageThresholds[c]);
	
	if (gGenerateIntermediateImages)
	{
		for (int c = 0; c < 3; c++)
		{
			string s = rgbImage.filename();
			if (c == 0)
				s += "_R_sk";
			else if (c == 1)
				s += "_G_sk";
			else s += "_B_sk";
			steerPyr[c].GeneratePGMimages(s.c_str());
		}
	}
	
	//Synthesize the steerable pyramid
	Image3ChnlReal rgbImageShrunk(rgbImage.width(), rgbImage.height());
	for (int c = 0; c < 3; c++)
		steerPyr[c].DoFullWaveletSynthesis(rgbImageShrunk[c]->img());
	/*
	stringstream denoiseParamSS;
	denoiseParamSS << "_";
	for (int c = 0; c < 3; c++)
	{
		if (c == 0)
			denoiseParamSS << "R";
		else if (c == 1)
			denoiseParamSS << "G";
		else denoiseParamSS << "B";
		
		denoiseParamSS << gManualShrinkageThresholds[c][0];
		for (int i = 1; i < gManualShrinkageThresholds[c].size(); i++)
			denoiseParamSS << "," << gManualShrinkageThresholds[c][i];
	}
	*/
	rgbImageShrunk.setFilename(rgbImage.filename());
	rgbImageShrunk.appendFilename("_dn");
	rgbImageShrunk.appendFilename(manualShrinkageThresholdStr);
	rgbImageShrunk.writeFile(1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movq %rsi, %rbx
movq %rdi, %r14
movq 0x1ce42(%rip), %rdi     # 0x2ffd0
leaq 0x118b4(%rip), %rsi     # 0x24a49
callq 0x32c0
movq %rax, %rdi
callq 0x3120
leaq 0xb8(%rsp), %rdi
callq 0xb390
leaq 0x98(%rsp), %rdi
movq %r14, %rsi
callq 0x33b0
leaq 0xb8(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0xb9be
leaq 0x98(%rsp), %rdi
callq 0x3548
xorl %r14d, %r14d
leaq (%rsp,%r14), %rdi
addq $0x140, %rdi            # imm = 0x140
callq 0x15294
addq $0x50, %r14
cmpq $0xf0, %r14
jne 0x131e4
movq %rbx, (%rsp)
leaq 0x140(%rsp), %r14
xorl %ebx, %ebx
pushq $0x1
popq %rbp
cmpq $0x3, %rbx
je 0x13242
movq 0xf0(%rsp), %rax
movq (%rax,%rbx,8), %rax
movq 0x38(%rax), %rsi
movl 0x28(%rax), %edx
movl 0x2c(%rax), %ecx
movq %r14, %rdi
movl %ebp, %r8d
callq 0x17960
incq %rbx
addq $0x50, %r14
jmp 0x13212
leaq 0x1d298(%rip), %rax     # 0x304e1
cmpb $0x1, (%rax)
jne 0x132c3
leaq 0xc0(%rsp), %r14
xorl %ebx, %ebx
leaq 0x8(%rsp), %r15
leaq 0x11801(%rip), %r12     # 0x24a65
leaq 0x117fd(%rip), %r13     # 0x24a68
leaq 0x117f0(%rip), %rbp     # 0x24a62
cmpq $0xf0, %rbx
je 0x132c3
movq %r15, %rdi
movq %r14, %rsi
callq 0x33b0
cmpq $0x50, %rbx
movq %r13, %rsi
cmoveq %r12, %rsi
testq %rbx, %rbx
cmoveq %rbp, %rsi
movq %r15, %rdi
callq 0x3510
leaq (%rsp,%rbx), %rdi
addq $0x140, %rdi            # imm = 0x140
movq 0x8(%rsp), %rsi
callq 0x193d6
movq %r15, %rdi
callq 0x3548
addq $0x50, %rbx
jmp 0x13272
leaq 0x140(%rsp), %r14
movq %r14, %rdi
callq 0x16762
movl %eax, %ebp
movq 0x1ccf4(%rip), %rdi     # 0x2ffd0
leaq 0x11728(%rip), %rsi     # 0x24a0b
callq 0x32c0
movq %rax, %rdi
movl %ebp, %esi
callq 0x34b0
leaq 0x11738(%rip), %rsi     # 0x24a31
movq %rax, %rdi
callq 0x32c0
movq %rax, %rdi
callq 0x3120
leaq 0x1d230(%rip), %r15     # 0x30540
movq 0x8(%r15), %rax
subq (%r15), %rax
sarq $0x3, %rax
incl %ebp
movslq %ebp, %r12
cmpq %r12, %rax
jne 0x135fb
movq 0x1cca0(%rip), %r12     # 0x2ffd0
leaq 0x11702(%rip), %rsi     # 0x24a39
movq %r12, %rdi
callq 0x32c0
movq %rax, %rdi
callq 0x3120
xorl %ebx, %ebx
cmpq $0x3, %rbx
je 0x13420
cmpq $0x1, %rbx
leaq 0x1171d(%rip), %rsi     # 0x24a7b
leaq 0x1170d(%rip), %rax     # 0x24a72
cmoveq %rax, %rsi
testq %rbx, %rbx
leaq 0x116f8(%rip), %rax     # 0x24a6b
cmoveq %rax, %rsi
movq %r12, %rdi
callq 0x32c0
movq %rax, %rdi
callq 0x3120
movq %r12, %rdi
leaq 0x116f2(%rip), %rsi     # 0x24a83
callq 0x32c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0xa, 0x10(%rax,%rcx)
imulq $0x18, %rbx, %rbp
movq (%r15,%rbp), %rcx
movsd (%rcx), %xmm0
movq %rax, %rdi
callq 0x3460
movq %rax, %rdi
callq 0x3120
movq %r12, %rdi
leaq 0x116c0(%rip), %rsi     # 0x24a8c
callq 0x32c0
addq %r15, %rbp
pushq $0x1
popq %r13
movq (%rbp), %rax
movq 0x8(%rbp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r13, %rcx
jbe 0x13410
movq (%r12), %rcx
movq -0x18(%rcx), %rcx
movq $0xa, 0x10(%r12,%rcx)
movsd (%rax,%r13,8), %xmm0
movq %r12, %rdi
callq 0x3460
incq %r13
jmp 0x133d8
movq %r12, %rdi
callq 0x3120
incq %rbx
jmp 0x13349
movq 0x1cba9(%rip), %rdi     # 0x2ffd0
callq 0x3120
xorl %ebx, %ebx
leaq 0x108(%rsp), %r12
cmpq $0xf0, %rbx
je 0x1346f
movq %r12, %rdi
movq %r15, %rsi
callq 0xedc2
leaq (%rsp,%rbx), %rdi
addq $0x140, %rdi            # imm = 0x140
movq %r12, %rsi
callq 0x18880
movq %r12, %rdi
callq 0x8a42
addq $0x50, %rbx
addq $0x18, %r15
jmp 0x13436
leaq 0x1d06b(%rip), %rax     # 0x304e1
cmpb $0x1, (%rax)
jne 0x134ed
xorl %ebx, %ebx
leaq 0x8(%rsp), %r12
leaq 0x11612(%rip), %r13     # 0x24a9b
leaq 0x11611(%rip), %rbp     # 0x24aa1
leaq 0x115fe(%rip), %r15     # 0x24a95
cmpq $0xf0, %rbx
je 0x134ed
movq %r12, %rdi
leaq 0xc0(%rsp), %rsi
callq 0x33b0
cmpq $0x50, %rbx
movq %rbp, %rsi
cmoveq %r13, %rsi
testq %rbx, %rbx
cmoveq %r15, %rsi
movq %r12, %rdi
callq 0x3510
leaq (%rsp,%rbx), %rdi
addq $0x140, %rdi            # imm = 0x140
movq 0x8(%rsp), %rsi
callq 0x193d6
movq %r12, %rdi
callq 0x3548
addq $0x50, %rbx
jmp 0x13497
movl 0xe0(%rsp), %esi
movl 0xe4(%rsp), %edx
leaq 0x8(%rsp), %rdi
callq 0xb5a8
xorl %ebx, %ebx
cmpq $0x3, %rbx
je 0x1352b
movq 0x40(%rsp), %rax
movq (%rax,%rbx,8), %rax
movq 0x38(%rax), %rsi
movq %r14, %rdi
callq 0x183d8
incq %rbx
addq $0x50, %r14
jmp 0x13507
leaq 0xc0(%rsp), %rsi
leaq 0x78(%rsp), %rdi
callq 0x33b0
movq (%rsp), %rbx
leaq 0x8(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0xa4ee
leaq 0x78(%rsp), %rdi
callq 0x3548
leaq 0x114e4(%rip), %rsi     # 0x24a45
leaq 0x8(%rsp), %rdi
callq 0x8686
leaq 0x58(%rsp), %rdi
movq %rbx, %rsi
callq 0x33b0
leaq 0x8(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0xa508
leaq 0x58(%rsp), %rdi
callq 0x3548
leaq 0x120(%rsp), %rdi
leaq 0x8(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0xbda4
leaq 0x120(%rsp), %rdi
callq 0x3548
leaq 0x8(%rsp), %rdi
callq 0xb686
movl $0xa0, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x140, %rdi            # imm = 0x140
callq 0x155fc
addq $-0x50, %rbx
cmpq $-0x50, %rbx
jne 0x135c2
leaq 0xb8(%rsp), %rdi
callq 0xb686
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
cmpq $0x48, %rbx
je 0x13329
leaq (%rbx,%r15), %rdi
movq %r12, %rsi
callq 0x80fc
addq $0x18, %rbx
jmp 0x135fd
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
jmp 0x1362b
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x3548
jmp 0x13663
jmp 0x136b7
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x3548
jmp 0x136da
movq %rax, %rbx
jmp 0x136da
jmp 0x13660
jmp 0x136b7
jmp 0x136b7
jmp 0x136b7
jmp 0x136b7
jmp 0x13683
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xb686
jmp 0x136ba
jmp 0x136b7
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x8a42
jmp 0x136ba
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3548
jmp 0x136ba
jmp 0x136b7
movq %rax, %rbx
testq %r14, %r14
je 0x136da
leaq 0xf0(%rsp), %r15
leaq (%r15,%r14), %rdi
callq 0x155fc
addq $-0x50, %r14
jne 0x136a4
jmp 0x136da
jmp 0x136b7
movq %rax, %rbx
movl $0xa0, %r14d
leaq (%rsp,%r14), %rdi
addq $0x140, %rdi            # imm = 0x140
callq 0x155fc
addq $-0x50, %r14
cmpq $-0x50, %r14
jne 0x136c0
leaq 0xb8(%rsp), %rdi
callq 0xb686
movq %rbx, %rdi
callq 0x34d0