Hi, I would like to ask how to extract data from the histogram (using the Statistics class) and save it to a .csv or Excel compatible file format to the SD card.
I want to collect all the values from the Statistics object such as mean(), median(), mode(), stdev(), min(), max(), and others and save them line by line into a CSV file for later analysis ( for example in Excel).
Could someone please guide me on how to format the output correctly and save it to the SD card using OpenMV?
Thank you in advance!
hist = img.get_histogram()
statistic = hist.get_statistics()
#Extract key statistics
mean_value = statistic.mean()
median_value = statistic.median()
mode_value = statistic.mode()
stdev_value = statistic.stdev()
min_value = statistic.min()
max_value = statistic.max()
l_mean = statistic.l_mean()
l_median = statistic.l_median()
l_mode = statistic.l_mode()
l_stdev = statistic.l_stdev()
l_min = statistic.l_min()
l_max = statistic.l_max()
a_mean = statistic.a_mean()
a_median = statistic.a_median()
a_mode = statistic.a_mode()
a_stdev = statistic.a_stdev()
a_min = statistic.a_min()
a_max = statistic.a_max()
b_mean = statistic.b_mean()
b_median = statistic.b_median()
b_mode = statistic.b_mode()
b_stdev = statistic.b_stdev()
b_min = statistic.b_min()
b_max = statistic.b_max()
# Print to serial monitor for debugging (line by line)
print("Grayscale Stats:")
print("Mean:", mean_value)
print("Median:", median_value)
print("Mode:", mode_value)
print("Stdev:", stdev_value)
print("Min:", min_value)
print("Max:", max_value)
print("-" \* 40)
print("LAB - L Channel:")
print("L_mean:", l_mean)
print("L_median:", l_median)
print("L_mode:", l_mode)
print("L_stdev:", l_stdev)
print("L_min:", l_min)
print("L_max:", l_max)
print("-" \* 40)
print("LAB - A Channel:")
print("A_mean:", a_mean)
print("A_median:", a_median)
print("A_mode:", a_mode)
print("A_stdev:", a_stdev)
print("A_min:", a_min)
print("A_max:", a_max)
print("-" \* 40)
print("LAB - B Channel:")
print("B_mean:", b_mean)
print("B_median:", b_median)
print("B_mode:", b_mode)
print("B_stdev:", b_stdev)
print("B_min:", b_min)
print("B_max:", b_max)
print("-" \* 40)