// File: rishabh-battulwar[P]imageprocessing/./include/ImageProc.h
// Function: ImageProc::apply_morphology(char const*, char const*, int, int)
void ImageProc::apply_morphology(const char *infile, const char *outfile, int width, int height)
{
	Image img_orig_bw("bw", width, height);
	Image img_binary("bw", width, height);
	Image img_shrinked("bw", width, height);
	Image img_thinned("bw", width, height);
	Image img_skeletonized("bw", width, height);
	Image img_unsharped("bw", width, height);
	Image img_modified("bw", width, height);
	Image img_modified_color("color", width, height);

	img_orig_bw.read_image(infile, img_orig_bw.cols, img_orig_bw.rows);

	//unsharp_mask(img_orig_bw, img_unsharp_masked);
	otsu_th(img_orig_bw, img_binary);
	img_binary.write_image("../output_images/morphology_binarized_img.raw", img_binary.cols, img_binary.rows);

	shrink(img_binary, img_shrinked);
	thin(img_binary, img_thinned);
	skeletonize(img_binary, img_skeletonized);

	img_shrinked.write_image("../output_images/morphology_shrinked_img.raw", img_shrinked.cols, img_shrinked.rows);
	img_thinned.write_image("../output_images/morphology_thinned_img.raw", img_thinned.cols, img_thinned.rows);
	img_skeletonized.write_image("../output_images/morphology_skeletonized_img.raw", img_skeletonized.cols, img_skeletonized.rows);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
leaq 0x631e(%rip), %rsi      # 0x1d5d4
movq %rsi, -0x130(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x7eb0
movq -0x130(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
leaq -0x58(%rbp), %rdi
callq 0x7eb0
jmp 0x172de
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
leaq 0x62e9(%rip), %rsi      # 0x1d5d4
leaq -0x88(%rbp), %rdi
callq 0x7eb0
jmp 0x172f9
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
leaq 0x62ce(%rip), %rsi      # 0x1d5d4
leaq -0xa8(%rbp), %rdi
callq 0x7eb0
jmp 0x17314
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
leaq 0x62b3(%rip), %rsi      # 0x1d5d4
leaq -0xc8(%rbp), %rdi
callq 0x7eb0
jmp 0x1732f
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
leaq 0x6298(%rip), %rsi      # 0x1d5d4
leaq -0xe8(%rbp), %rdi
callq 0x7eb0
jmp 0x1734a
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
leaq 0x627d(%rip), %rsi      # 0x1d5d4
leaq -0x108(%rbp), %rdi
callq 0x7eb0
jmp 0x17365
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
leaq 0x5276(%rip), %rsi      # 0x1c5e8
leaq -0x128(%rbp), %rdi
callq 0x7eb0
jmp 0x17380
movq -0x8(%rbp), %rsi
movl -0x30(%rbp), %edx
movl -0x2c(%rbp), %ecx
leaq -0x38(%rbp), %rdi
callq 0x7f70
jmp 0x17395
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x17590
jmp 0x173a4
movl -0x50(%rbp), %edx
movl -0x4c(%rbp), %ecx
leaq 0x596e(%rip), %rsi      # 0x1cd1f
leaq -0x58(%rbp), %rdi
callq 0x8150
jmp 0x173bc
leaq -0x58(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x179a0
jmp 0x173ce
leaq -0x58(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x186a0
jmp 0x173e0
leaq -0x58(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x19220
jmp 0x173f2
movl -0x80(%rbp), %edx
movl -0x7c(%rbp), %ecx
leaq 0x594e(%rip), %rsi      # 0x1cd4d
leaq -0x88(%rbp), %rdi
callq 0x8150
jmp 0x1740d
movl -0xa0(%rbp), %edx
movl -0x9c(%rbp), %ecx
leaq 0x595a(%rip), %rsi      # 0x1cd7a
leaq -0xa8(%rbp), %rdi
callq 0x8150
jmp 0x1742e
movl -0xc0(%rbp), %edx
movl -0xbc(%rbp), %ecx
leaq 0x5965(%rip), %rsi      # 0x1cda6
leaq -0xc8(%rbp), %rdi
callq 0x8150
jmp 0x1744f
leaq -0x128(%rbp), %rdi
callq 0x1b2c0
leaq -0x108(%rbp), %rdi
callq 0x1b2c0
leaq -0xe8(%rbp), %rdi
callq 0x1b2c0
leaq -0xc8(%rbp), %rdi
callq 0x1b2c0
leaq -0xa8(%rbp), %rdi
callq 0x1b2c0
leaq -0x88(%rbp), %rdi
callq 0x1b2c0
leaq -0x58(%rbp), %rdi
callq 0x1b2c0
leaq -0x38(%rbp), %rdi
callq 0x1b2c0
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1757a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x17571
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x17565
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x17559
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1754d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x17541
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x17535
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x1b2c0
leaq -0x108(%rbp), %rdi
callq 0x1b2c0
leaq -0xe8(%rbp), %rdi
callq 0x1b2c0
leaq -0xc8(%rbp), %rdi
callq 0x1b2c0
leaq -0xa8(%rbp), %rdi
callq 0x1b2c0
leaq -0x88(%rbp), %rdi
callq 0x1b2c0
leaq -0x58(%rbp), %rdi
callq 0x1b2c0
leaq -0x38(%rbp), %rdi
callq 0x1b2c0
movq -0x60(%rbp), %rdi
callq 0x2360
nopl (%rax)