Skip to content

Commit

Permalink
Add comparison scripts for exposure fusion
Browse files Browse the repository at this point in the history
  • Loading branch information
mcoduoza committed Jun 4, 2024
1 parent a1ff174 commit a3ba159
Show file tree
Hide file tree
Showing 9 changed files with 653 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import numpy as np
import pandas as pd

trace_file_path = "./out.txt"

pyramid_width_list = [1264, 632, 316, 158]
pyramid_height_list = [1136, 568, 284, 142]

pyramid_level = 3

pyramid_width = pyramid_width_list[pyramid_level]
pyramid_height = pyramid_height_list[pyramid_level]

kayvon_pyramid = np.zeros((pyramid_height, pyramid_width))



# First load Kayvon's weight pyramid
k_bright_lPyramid_filepath = f"/aha/cs348v_camera_asst/bright_lPyramid_level_{pyramid_level}.txt"


k_bright_lPyramid_file = open(k_bright_lPyramid_filepath, 'r')
line = k_bright_lPyramid_file.readline()

y = 0
while(line):
line = line.strip()
row = line.split(', ')

for x in range(len(row)):
kayvon_pyramid[y][x] = float(row[x])

line = k_bright_lPyramid_file.readline()
y += 1

k_bright_lPyramid_file.close()


# print(kayvon_pyramid[0][1][0])
# print(kayvon_pyramid[0][1][1])
# print(kayvon_pyramid[0][1][2])




# Now, compare to my exposure fusion output
tolerance = 0.001

trace_file = open(trace_file_path, "r")

line = trace_file.readline()
while(line):
if 'Store' in line:
line = line.strip()
components = line.split(' = ')

indices = components[0].split('(')[1].strip(')').split(', ')
my_weight_value = float(components[1])

x = int(indices[0])
y = int(indices[1])

abs_difference = abs(my_weight_value - kayvon_pyramid[y][x])

if (abs_difference > tolerance):
print(f"At x = {x}, y = {y}, expected {kayvon_pyramid[y][x]} but got {my_weight_value}. Difference is {abs_difference}.")

line = trace_file.readline()

trace_file.close()
#print(my_pixels)


Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import numpy as np
import pandas as pd

trace_file_path = "./out.txt"

pyramid_width_list = [1264, 632, 316, 158]
pyramid_height_list = [1136, 568, 284, 142]

pyramid_level = 0

pyramid_width = pyramid_width_list[pyramid_level]
pyramid_height = pyramid_height_list[pyramid_level]

kayvon_pyramid = np.zeros((pyramid_height, pyramid_width))



# First load Kayvon's weight pyramid
k_bright_weight_gPyramid_filepath = f"/aha/cs348v_camera_asst/bright_weight_gPyrmaid_level_{pyramid_level}.txt"


k_bright_weight_gPyramid_file = open(k_bright_weight_gPyramid_filepath, 'r')
line = k_bright_weight_gPyramid_file.readline()

y = 0
while(line):
line = line.strip()
row = line.split(', ')

for x in range(len(row)):
kayvon_pyramid[y][x] = float(row[x])

line = k_bright_weight_gPyramid_file.readline()
y += 1

k_bright_weight_gPyramid_file.close()


# print(kayvon_pyramid[0][1][0])
# print(kayvon_pyramid[0][1][1])
# print(kayvon_pyramid[0][1][2])




# Now, compare to my exposure fusion output
tolerance = 0.001

trace_file = open(trace_file_path, "r")

line = trace_file.readline()
while(line):
if 'Store' in line:
line = line.strip()
components = line.split(' = ')

indices = components[0].split('(')[1].strip(')').split(', ')
my_weight_value = float(components[1])

x = int(indices[0])
y = int(indices[1])

abs_difference = abs(my_weight_value - kayvon_pyramid[y][x])

if (abs_difference > tolerance):
print(f"At x = {x}, y = {y}, expected {kayvon_pyramid[y][x]} but got {my_weight_value}. Difference is {abs_difference}.")

line = trace_file.readline()

trace_file.close()
#print(my_pixels)


Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import numpy as np
import pandas as pd

trace_file_path = "./out.txt"

pyramid_width_list = [1264, 632, 316, 158]
pyramid_height_list = [1136, 568, 284, 142]

pyramid_level = 0

pyramid_width = pyramid_width_list[pyramid_level]
pyramid_height = pyramid_height_list[pyramid_level]

kayvon_pyramid = np.zeros((pyramid_height, pyramid_width))



# First load Kayvon's weight pyramid
k_dark_lPyramid_filepath = f"/aha/cs348v_camera_asst/dark_lPyramid_level_{pyramid_level}.txt"


k_dark_lPyramid_file = open(k_dark_lPyramid_filepath, 'r')
line = k_dark_lPyramid_file.readline()

y = 0
while(line):
line = line.strip()
row = line.split(', ')

for x in range(len(row)):
kayvon_pyramid[y][x] = float(row[x])

line = k_dark_lPyramid_file.readline()
y += 1

k_dark_lPyramid_file.close()


# print(kayvon_pyramid[0][1][0])
# print(kayvon_pyramid[0][1][1])
# print(kayvon_pyramid[0][1][2])




# Now, compare to my exposure fusion output
tolerance = 0.001

trace_file = open(trace_file_path, "r")

line = trace_file.readline()
while(line):
if 'Store' in line:
line = line.strip()
components = line.split(' = ')

indices = components[0].split('(')[1].strip(')').split(', ')
my_weight_value = float(components[1])

x = int(indices[0])
y = int(indices[1])

abs_difference = abs(my_weight_value - kayvon_pyramid[y][x])

if (abs_difference > tolerance):
print(f"At x = {x}, y = {y}, expected {kayvon_pyramid[y][x]} but got {my_weight_value}. Difference is {abs_difference}.")

line = trace_file.readline()

trace_file.close()
#print(my_pixels)


Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import numpy as np
import pandas as pd

trace_file_path = "./out.txt"

pyramid_width_list = [1264, 632, 316, 158]
pyramid_height_list = [1136, 568, 284, 142]

pyramid_level = 0

pyramid_width = pyramid_width_list[pyramid_level]
pyramid_height = pyramid_height_list[pyramid_level]

kayvon_pyramid = np.zeros((pyramid_height, pyramid_width))



# First load Kayvon's weight pyramid
k_dark_weight_gPyramid_filepath = f"/aha/cs348v_camera_asst/dark_weight_gPyrmaid_level_{pyramid_level}.txt"


k_dark_weight_gPyramid_file = open(k_dark_weight_gPyramid_filepath, 'r')
line = k_dark_weight_gPyramid_file.readline()

y = 0
while(line):
line = line.strip()
row = line.split(', ')

for x in range(len(row)):
kayvon_pyramid[y][x] = float(row[x])

line = k_dark_weight_gPyramid_file.readline()
y += 1

k_dark_weight_gPyramid_file.close()


# print(kayvon_pyramid[0][1][0])
# print(kayvon_pyramid[0][1][1])
# print(kayvon_pyramid[0][1][2])




# Now, compare to my exposure fusion output
tolerance = 0.001

trace_file = open(trace_file_path, "r")

line = trace_file.readline()
while(line):
if 'Store' in line:
line = line.strip()
components = line.split(' = ')

indices = components[0].split('(')[1].strip(')').split(', ')
my_weight_value = float(components[1])

x = int(indices[0])
y = int(indices[1])

abs_difference = abs(my_weight_value - kayvon_pyramid[y][x])

if (abs_difference > tolerance):
print(f"At x = {x}, y = {y}, expected {kayvon_pyramid[y][x]} but got {my_weight_value}. Difference is {abs_difference}.")

line = trace_file.readline()

trace_file.close()
#print(my_pixels)


Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import numpy as np
import pandas as pd

trace_file_path = "./out.txt"


im_width = 1250
im_height = 1120
num_color_channels = 3

kayvon_image = np.zeros((im_height, im_width, num_color_channels))



# First load Kayvon's exposure fusion output
k_EF_red_filepath = f"/aha/cs348v_camera_asst/post_exposure_fusion_red_out.txt"
k_EF_green_filepath = f"/aha/cs348v_camera_asst/post_exposure_fusion_green_out.txt"
k_EF_blue_filepath = f"/aha/cs348v_camera_asst/post_exposure_fusion_blue_out.txt"


k_EF_red_file = open(k_EF_red_filepath, 'r')
k_EF_green_file = open(k_EF_green_filepath, 'r')
k_EF_blue_file = open(k_EF_blue_filepath, 'r')

red_line = k_EF_red_file.readline()
green_line = k_EF_green_file.readline()
blue_line = k_EF_blue_file.readline()

y = 0
while(red_line):
red_line = red_line.strip()
red_row = red_line.split(', ')

green_line = green_line.strip()
green_row = green_line.split(', ')

blue_line = blue_line.strip()
blue_row = blue_line.split(', ')

for x in range(len(red_row)):
kayvon_image[y][x][0] = red_row[x]
kayvon_image[y][x][1] = green_row[x]
kayvon_image[y][x][2] = blue_row[x]

red_line = k_EF_red_file.readline()
green_line = k_EF_green_file.readline()
blue_line = k_EF_blue_file.readline()
y += 1

k_EF_red_file.close()
k_EF_green_file.close()
k_EF_blue_file.close()


# print(kayvon_image[0][1][0])
# print(kayvon_image[0][1][1])
# print(kayvon_image[0][1][2])




# Now, compare to my exposure fusion output
tolerance = 0.001

trace_file = open(trace_file_path, "r")

line = trace_file.readline()
while(line):
if 'Store' in line:
line = line.strip()
components = line.split(' = ')

indices = components[0].split('(')[1].strip(')').split(', ')
pixel_value = float(components[1])

x = int(indices[0])
y = int(indices[1])
c = int(indices[2])

abs_difference = abs(pixel_value - kayvon_image[y][x][c])

if (abs_difference > tolerance):
print(f"At x = {x}, y = {y}, c = {c} expected {kayvon_image[y][x][c]} but got {pixel_value}. Difference is {abs_difference}.")

line = trace_file.readline()

trace_file.close()
#print(my_pixels)


Loading

0 comments on commit a3ba159

Please sign in to comment.