// File: /workspace/github_cpp_makefile_star2_O2/kebwi[P]Trifid/src/ImageProcs.cpp
// Function: denoiseGrayImage(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 denoiseGrayImage(string filename, string manualShrinkageThresholdStr)
{
	cout << "Denoising gray image..." << endl;
	
	//Open the image
	ImageReal grayImage;
	grayImage.readFile(filename);
	
	//Construct a steerable pyramid of the image
	SteerablePyramid steerPyr;
	steerPyr.DoFullWaveletAnalysis(grayImage.img(), grayImage.width(), grayImage.height(), true);
	
	if (gGenerateIntermediateImages)
		steerPyr.GeneratePGMimages(grayImage.filename().c_str());
	
	int numLevels = steerPyr.NumLevels();
	cout << "Steerable pyramid will be built with " << numLevels << " levels" << endl;
	if (gManualShrinkageThresholds[0].size() != numLevels + 1)
		gManualShrinkageThresholds[0].resize(numLevels + 1);
	cout << "Thresholds:" << endl;
	cout << "  H:  " << setw(10) << gManualShrinkageThresholds[0][0] << endl;
	cout << "  B:  ";
	for (int i = 1; i < gManualShrinkageThresholds[0].size(); i++)
		cout << setw(10) << gManualShrinkageThresholds[0][i];
	cout << endl << endl;
	
	//Shrink the coefficients
	steerPyr.SoftThreshold(gManualShrinkageThresholds[0]);
	
	if (gGenerateIntermediateImages)
	{
		string s = grayImage.filename() + "_sk";
		steerPyr.GeneratePGMimages(s.c_str());
	}
	
	//Synthesize the steerable pyramid
	ImageReal grayImageShrunk(grayImage.width(), grayImage.height());
	steerPyr.DoFullWaveletSynthesis(grayImageShrunk.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];
	}
	*/
	grayImageShrunk.setFilename(grayImage.filename());
	grayImageShrunk.appendFilename("_dn");
	grayImageShrunk.appendFilename(manualShrinkageThresholdStr);
	grayImageShrunk.writeFile(1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rsi, %rbx
movq %rdi, %r14
movq 0x1d23c(%rip), %rdi     # 0x2ffd0
leaq 0x11c58(%rip), %rsi     # 0x249f3
callq 0x32c0
movq %rax, %rdi
callq 0x3120
leaq 0x40(%rsp), %rdi
callq 0xa588
leaq 0xf8(%rsp), %rdi
movq %r14, %rsi
callq 0x33b0
leaq 0x40(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0xac74
leaq 0xf8(%rsp), %rdi
callq 0x3548
leaq 0x118(%rsp), %rdi
callq 0x15294
movq 0x78(%rsp), %rsi
movl 0x68(%rsp), %edx
movl 0x6c(%rsp), %ecx
leaq 0x118(%rsp), %rdi
pushq $0x1
popq %r8
callq 0x17960
leaq 0x1d6ce(%rip), %r15     # 0x304e1
cmpb $0x1, (%r15)
jne 0x12e3f
leaq 0x48(%rsp), %rsi
movq %rsp, %rdi
callq 0x33b0
movq (%rsp), %rsi
leaq 0x118(%rsp), %rdi
callq 0x193d6
movq %rsp, %rdi
callq 0x3548
leaq 0x118(%rsp), %rdi
callq 0x16762
movl %eax, %ebp
movq 0x1d17b(%rip), %rdi     # 0x2ffd0
leaq 0x11baf(%rip), %rsi     # 0x24a0b
callq 0x32c0
movq %rax, %rdi
movl %ebp, %esi
callq 0x34b0
leaq 0x11bbf(%rip), %rsi     # 0x24a31
movq %rax, %rdi
callq 0x32c0
movq %rax, %rdi
callq 0x3120
leaq 0x1d6b7(%rip), %r12     # 0x30540
movq 0x8(%r12), %rax
subq (%r12), %rax
sarq $0x3, %rax
incl %ebp
movslq %ebp, %rsi
cmpq %rsi, %rax
je 0x12eac
leaq 0x1d699(%rip), %rdi     # 0x30540
callq 0x80fc
movq 0x1d11d(%rip), %rdi     # 0x2ffd0
leaq 0x11b7f(%rip), %rsi     # 0x24a39
callq 0x32c0
movq %rax, %rdi
callq 0x3120
movq 0x1d102(%rip), %rdi     # 0x2ffd0
leaq 0x11bb0(%rip), %rsi     # 0x24a85
callq 0x32c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0xa, 0x10(%rax,%rcx)
movq (%r12), %rcx
movsd (%rcx), %xmm0
movq %rax, %rdi
callq 0x3460
movq %rax, %rdi
callq 0x3120
movq 0x1d0c7(%rip), %r14     # 0x2ffd0
leaq 0x11b7e(%rip), %rsi     # 0x24a8e
movq %r14, %rdi
callq 0x32c0
pushq $0x1
popq %r13
movq (%r12), %rax
movq 0x8(%r12), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r13, %rcx
jbe 0x12f54
movq (%r14), %rcx
movq -0x18(%rcx), %rcx
movq $0xa, 0x10(%r14,%rcx)
movsd (%rax,%r13,8), %xmm0
movq %r14, %rdi
callq 0x3460
incq %r13
jmp 0x12f1c
movq 0x1d075(%rip), %rdi     # 0x2ffd0
callq 0x3120
movq %rax, %rdi
callq 0x3120
leaq 0x1d5d1(%rip), %rsi     # 0x30540
leaq 0x80(%rsp), %rdi
callq 0xedc2
leaq 0x118(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x18880
leaq 0x80(%rsp), %rdi
callq 0x8a42
cmpb $0x1, (%r15)
jne 0x12ff3
leaq 0x48(%rsp), %rsi
leaq 0xd8(%rsp), %rdi
callq 0x33b0
leaq 0x11ae6(%rip), %rdx     # 0x24aa3
movq %rsp, %rdi
leaq 0xd8(%rsp), %rsi
callq 0x1390d
leaq 0xd8(%rsp), %rdi
callq 0x3548
movq (%rsp), %rsi
leaq 0x118(%rsp), %rdi
callq 0x193d6
movq %rsp, %rdi
callq 0x3548
movl 0x68(%rsp), %esi
movl 0x6c(%rsp), %edx
movq %rsp, %rdi
callq 0xa62e
movq 0x38(%rsp), %rsi
leaq 0x118(%rsp), %rdi
callq 0x183d8
leaq 0x48(%rsp), %rsi
leaq 0xb8(%rsp), %rdi
callq 0x33b0
movq %rsp, %rdi
leaq 0xb8(%rsp), %rsi
callq 0xa4ee
leaq 0xb8(%rsp), %rdi
callq 0x3548
leaq 0x119fa(%rip), %rsi     # 0x24a45
movq %rsp, %rdi
callq 0x8686
leaq 0x98(%rsp), %rdi
movq %rbx, %rsi
callq 0x33b0
movq %rsp, %rdi
leaq 0x98(%rsp), %rsi
callq 0xa508
leaq 0x98(%rsp), %rdi
callq 0x3548
leaq 0x168(%rsp), %rdi
movq %rsp, %rsi
pushq $0x1
popq %rdx
callq 0xb028
leaq 0x168(%rsp), %rdi
callq 0x3548
movq %rsp, %rdi
callq 0xa6a6
leaq 0x118(%rsp), %rdi
callq 0x155fc
leaq 0x40(%rsp), %rdi
callq 0xa6a6
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x130e2
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
jmp 0x130e8
jmp 0x1314e
movq %rax, %rbx
movq %rsp, %rdi
callq 0x3548
jmp 0x13151
jmp 0x1314e
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
jmp 0x13109
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x3548
jmp 0x13142
jmp 0x1314e
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x8a42
jmp 0x13151
jmp 0x1314e
jmp 0x1313a
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x3548
jmp 0x1315e
movq %rax, %rbx
jmp 0x1315e
movq %rax, %rbx
movq %rsp, %rdi
callq 0xa6a6
jmp 0x13151
jmp 0x1314e
movq %rax, %rbx
leaq 0x118(%rsp), %rdi
callq 0x155fc
leaq 0x40(%rsp), %rdi
callq 0xa6a6
movq %rbx, %rdi
callq 0x34d0