-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfromImage.py
More file actions
75 lines (53 loc) · 2.79 KB
/
Copy pathfromImage.py
File metadata and controls
75 lines (53 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import sys
from pythonLib.formImageLib import *
import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Process photon data and generate a histogram-based depth image.")
parser.add_argument("--input_file", help="Path to input photon .h5 file")
parser.add_argument("--output_image", help="Optional output image file name (e.g., depth_image.png)")
parser.add_argument("--output_file", help="Optional output h5 file name (e.g., depth_image.png)")
parser.add_argument("--bin_number", type=int, help="Number of histogram bins")
parser.add_argument("--min_range", type=float, help="Minimum range value for histogram")
parser.add_argument("--bin_width", type=float, help="The width of each bin")
input_file_path = './positiveResult/histogram/test1_len.txt'
# extract the name of the file generated a new file with the same name
output_image_name = input_file_path.split('/')[-1]
output_image_name = output_image_name.split('.')[0]
output_image_name = output_image_name + '_depth.png'
range_min = 500
bin_width = 80
args = parser.parse_args()
input_bin_number = 35
# Override with CLI args
if args.input_file:
input_file_path = args.input_file
if args.bin_number:
input_bin_number = args.bin_number
if args.min_range:
range_min = args.min_range
if args.bin_width:
bin_width = args.bin_width
if args.output_image:
output_image_name = args.output_image
range_max = range_min + input_bin_number * bin_width
myRange = [range_min,range_max]
pixels, image_width, image_heigh = decode_file(input_file_path)
# print(pixels[200][300])
# image = form_image(pixels, image_heigh,image_width)
image, illegal_photon, stamped_histogram, stamped_collosion = form_histogram_image(pixels,image_width,image_heigh,bin_number=input_bin_number,range_distance=myRange)
# stamped_histogram= np.rot90(stamped_histogram, k=-1, axes=(0, 1))
# stamped_collosioin= np.rot90(stamped_collosioin, k=-1, axes=(0, 1))
# image = np.rot90(image, k=-1)
# stamped_histogram = stamped_histogram[::-1, ...]
# stamped_collosioin = stamped_collosioin[::-1, ...]
# image = image[::-1, ...]
left_index = 70 + 8
right_index = 180 + 8
bottom_index = 35
top_index = 143
print(np.sum(stamped_histogram))
# image_width, image_heigh, bin_width, stamped_histogram, stamped_collosion = crop_image(left_index,right_index,bottom_index,top_index,stamped_histogram,stamped_collosion)
save_image(image,None,output_image_name,distance_range=myRange)
if args.output_file:
outputFile = args.output_file
save_histogram_to_h5(outputFile, stamped_histogram, stamped_collosion ,range_min, range_max, image_width, image_heigh, input_bin_number)