// File: 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
movq %rsp, %rbp
subq $0x290, %rsp            # imm = 0x290
movq %rdi, -0x200(%rbp)
movq %rsi, -0x208(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq 0x35c98(%rip), %rdi     # 0x59fd0
leaq 0x27733(%rip), %rsi     # 0x4ba72
callq 0x4390
movq %rax, %rdi
movq 0x35c6a(%rip), %rsi     # 0x59fb8
callq 0x43d0
leaq -0x50(%rbp), %rdi
callq 0x155e0
movq -0x200(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4180
jmp 0x2436e
leaq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x16200
jmp 0x2437d
leaq -0x70(%rbp), %rdi
callq 0x46c8
leaq -0xd0(%rbp), %rdi
callq 0x293b0
jmp 0x24394
leaq -0x50(%rbp), %rdi
callq 0xf2c0
movq %rax, -0x210(%rbp)
jmp 0x243a6
leaq -0x50(%rbp), %rdi
callq 0xedd0
movl %eax, -0x214(%rbp)
jmp 0x243b7
leaq -0x50(%rbp), %rdi
callq 0xedf0
movl %eax, -0x218(%rbp)
jmp 0x243c8
movl -0x218(%rbp), %ecx
movl -0x214(%rbp), %edx
movq -0x210(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
movl $0x1, %r8d
callq 0x2d2c0
jmp 0x243ef
leaq 0x361bb(%rip), %rax     # 0x5a5b1
testb $0x1, (%rax)
je 0x24495
leaq -0xf0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xf090
jmp 0x24411
leaq -0xf0(%rbp), %rdi
callq 0x4160
movq %rax, %rsi
leaq -0xd0(%rbp), %rdi
callq 0x30350
jmp 0x2442e
leaq -0xf0(%rbp), %rdi
callq 0x46c8
jmp 0x24495
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x24994
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x46c8
jmp 0x24994
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x24988
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x46c8
jmp 0x24988
leaq -0xd0(%rbp), %rdi
callq 0x2bac0
movl %eax, -0x21c(%rbp)
jmp 0x244a9
movl -0x21c(%rbp), %eax
movl %eax, -0xf4(%rbp)
movq 0x35b14(%rip), %rdi     # 0x59fd0
leaq 0x275c7(%rip), %rsi     # 0x4ba8a
callq 0x4390
movq %rax, -0x228(%rbp)
jmp 0x244d1
movq -0x228(%rbp), %rdi
movl -0xf4(%rbp), %esi
callq 0x4600
movq %rax, -0x230(%rbp)
jmp 0x244ec
movq -0x230(%rbp), %rdi
leaq 0x275b6(%rip), %rsi     # 0x4bab0
callq 0x4390
movq %rax, -0x238(%rbp)
jmp 0x24508
movq -0x238(%rbp), %rdi
movq 0x35aa2(%rip), %rsi     # 0x59fb8
callq 0x43d0
jmp 0x2451d
leaq 0x360ec(%rip), %rdi     # 0x5a610
callq 0xe5c0
movl -0xf4(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
je 0x24555
movl -0xf4(%rbp), %eax
incl %eax
movslq %eax, %rsi
leaq 0x360c4(%rip), %rdi     # 0x5a610
callq 0xe5e0
jmp 0x24553
jmp 0x24555
movq 0x35a74(%rip), %rdi     # 0x59fd0
leaq 0x27555(%rip), %rsi     # 0x4bab8
callq 0x4390
movq %rax, -0x240(%rbp)
jmp 0x24571
movq -0x240(%rbp), %rdi
movq 0x35a39(%rip), %rsi     # 0x59fb8
callq 0x43d0
jmp 0x24586
movq 0x35a43(%rip), %rdi     # 0x59fd0
leaq 0x27570(%rip), %rsi     # 0x4bb04
callq 0x4390
movq %rax, -0x248(%rbp)
jmp 0x245a2
movl $0xa, %edi
callq 0xe410
movl %eax, -0x24c(%rbp)
jmp 0x245b4
movq -0x248(%rbp), %rdi
movl -0x24c(%rbp), %eax
movl %eax, -0xf8(%rbp)
movl -0xf8(%rbp), %esi
callq 0x4430
movq %rax, -0x258(%rbp)
jmp 0x245db
leaq 0x3602e(%rip), %rdi     # 0x5a610
xorl %eax, %eax
movl %eax, %esi
callq 0xe670
movq -0x258(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x4670
movq %rax, -0x260(%rbp)
jmp 0x24604
movq -0x260(%rbp), %rdi
movq 0x359a6(%rip), %rsi     # 0x59fb8
callq 0x43d0
jmp 0x24619
movq 0x359b0(%rip), %rdi     # 0x59fd0
leaq 0x274e6(%rip), %rsi     # 0x4bb0d
callq 0x4390
jmp 0x2462e
movl $0x1, -0xfc(%rbp)
movslq -0xfc(%rbp), %rax
movq %rax, -0x268(%rbp)
leaq 0x35fc3(%rip), %rdi     # 0x5a610
callq 0xe5c0
movq %rax, %rcx
movq -0x268(%rbp), %rax
cmpq %rcx, %rax
jae 0x246d5
movl $0xa, %edi
callq 0xe410
movl %eax, -0x26c(%rbp)
jmp 0x24673
movl -0x26c(%rbp), %eax
movl %eax, -0x100(%rbp)
movl -0x100(%rbp), %esi
movq 0x35944(%rip), %rdi     # 0x59fd0
callq 0x4430
movq %rax, -0x278(%rbp)
jmp 0x2469a
movslq -0xfc(%rbp), %rsi
leaq 0x35f68(%rip), %rdi     # 0x5a610
callq 0xe670
movq -0x278(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x4670
jmp 0x246bf
jmp 0x246c1
movl -0xfc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xfc(%rbp)
jmp 0x24638
movq 0x358f4(%rip), %rdi     # 0x59fd0
movq 0x358d5(%rip), %rsi     # 0x59fb8
callq 0x43d0
movq %rax, -0x280(%rbp)
jmp 0x246f1
movq -0x280(%rbp), %rdi
movq 0x358b9(%rip), %rsi     # 0x59fb8
callq 0x43d0
jmp 0x24706
leaq 0x35f03(%rip), %rsi     # 0x5a610
leaq -0x118(%rbp), %rdi
callq 0x1d890
jmp 0x2471b
leaq -0xd0(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x2ec80
jmp 0x24730
leaq -0x118(%rbp), %rdi
callq 0xe260
leaq 0x35e6e(%rip), %rax     # 0x5a5b1
testb $0x1, (%rax)
je 0x24808
leaq -0x158(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xf090
jmp 0x2475e
leaq 0x273bd(%rip), %rdx     # 0x4bb22
leaq -0x138(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x25b40
jmp 0x2477a
leaq -0x158(%rbp), %rdi
callq 0x46c8
leaq -0x138(%rbp), %rdi
callq 0x4160
movq %rax, %rsi
leaq -0xd0(%rbp), %rdi
callq 0x30350
jmp 0x247a3
leaq -0x138(%rbp), %rdi
callq 0x46c8
jmp 0x24808
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x118(%rbp), %rdi
callq 0xe260
jmp 0x24988
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x46c8
jmp 0x24988
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x46c8
jmp 0x24988
leaq -0x50(%rbp), %rdi
callq 0xedd0
movl %eax, -0x284(%rbp)
jmp 0x24819
leaq -0x50(%rbp), %rdi
callq 0xedf0
movl %eax, -0x288(%rbp)
jmp 0x2482a
movl -0x288(%rbp), %edx
movl -0x284(%rbp), %esi
leaq -0x198(%rbp), %rdi
callq 0x15710
jmp 0x24844
leaq -0x198(%rbp), %rdi
callq 0xf2c0
movq %rax, -0x290(%rbp)
jmp 0x24859
movq -0x290(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
callq 0x2e250
jmp 0x2486e
leaq -0x1b8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xf090
jmp 0x24880
leaq -0x198(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x154b0
jmp 0x24895
leaq -0x1b8(%rbp), %rdi
callq 0x46c8
leaq 0x2721c(%rip), %rsi     # 0x4bac4
leaq -0x198(%rbp), %rdi
callq 0xf220
jmp 0x248b6
movq -0x208(%rbp), %rsi
leaq -0x1d8(%rbp), %rdi
callq 0x4180
jmp 0x248cb
leaq -0x198(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x154f0
jmp 0x248e0
leaq -0x1d8(%rbp), %rdi
callq 0x46c8
leaq -0x1f8(%rbp), %rdi
leaq -0x198(%rbp), %rsi
movl $0x1, %edx
callq 0x168c0
jmp 0x24906
leaq -0x1f8(%rbp), %rdi
callq 0x46c8
leaq -0x198(%rbp), %rdi
callq 0x157e0
leaq -0xd0(%rbp), %rdi
callq 0x299e0
leaq -0x50(%rbp), %rdi
callq 0x157e0
addq $0x290, %rsp            # imm = 0x290
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x2497c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x46c8
jmp 0x2497c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x46c8
leaq -0x198(%rbp), %rdi
callq 0x157e0
leaq -0xd0(%rbp), %rdi
callq 0x299e0
leaq -0x50(%rbp), %rdi
callq 0x157e0
movq -0x78(%rbp), %rdi
callq 0x4620
nopw %cs:(%rax,%rax)