Skip to content

Commit

Permalink
stats about infinities
Browse files Browse the repository at this point in the history
  • Loading branch information
wkjarosz committed Feb 18, 2024
1 parent 557e91d commit 725e025
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
6 changes: 3 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

##

- [ ] have spdlog output to the log window
- [x] have spdlog output to the log window
- [ ] load multiplate images/entire directories
- [ ] fix reference image index when closing image
- [ ] render pixel grid in the shader
- [ ] figure out how to better handle channels dropdown with channel groups and arbitrary channels
- [ ] improve statistics
- [ ] compute min/max/avg ignoring infinities, and report # of infinities
- [x] compute min/max/avg ignoring infinities, and report # of infinities
- [ ] compute statistics also over selection
- [ ] compute pixel hover (and statistics) while considering the blend mode
- [ ] account for blend mode when computing pixel hover (and statistics)
- [ ] figure our threading while considering emscripten
- [ ] selection support
- [ ] command palette/improved hotkey support
Expand Down
4 changes: 3 additions & 1 deletion src/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ PixelStatistics::PixelStatistics(const Array2Df &img, float the_exposure, AxisSc
float val = img(i);

if (isnan(val))
++invalid_pixels;
++nan_pixels;
else if (isinf(val))
++inf_pixels;
else
{
++valid_pixels;
Expand Down
3 changes: 2 additions & 1 deletion src/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ struct PixelStatistics
float minimum;
float maximum;
float average;
int invalid_pixels = 0;
int nan_pixels = 0;
int inf_pixels = 0;

Histogram histogram;

Expand Down
10 changes: 6 additions & 4 deletions src/image_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ void Image::draw_info()
// ImGui::Text("%-6.3g", stats->minimum), ImGui::TableNextColumn();
// ImGui::Text("%-6.3g", stats->average), ImGui::TableNextColumn();
// ImGui::Text("%-6.3g", stats->maximum), ImGui::TableNextColumn();
// ImGui::Text("%d", stats->invalid_pixels);
// ImGui::Text("%d", stats->nan_pixels);
// // ImGui::PopFont();
// }
// ImGui::EndTable();
Expand Down Expand Up @@ -541,8 +541,8 @@ void Image::draw_info()
ImGui::TableHeadersRow();
ImGui::PopFont();

const char *stat_names[4] = {"Min", "Avg", "Max", "# of NaNs"};
constexpr int NUM_STATS = sizeof(stat_names) / sizeof(stat_names[0]);
const char *stat_names[] = {"Min", "Avg", "Max", "# of NaNs", "# of Infs"};
constexpr int NUM_STATS = sizeof(stat_names) / sizeof(stat_names[0]);
for (int s = 0; s < NUM_STATS; ++s)
{
ImGui::PushFont(bold_font);
Expand All @@ -559,7 +559,9 @@ void Image::draw_info()
case 0: ImGui::Text("%-6.3g", channel_stats[c]->minimum); break;
case 1: ImGui::Text("%-6.3g", channel_stats[c]->average); break;
case 2: ImGui::Text("%-6.3g", channel_stats[c]->maximum); break;
default: ImGui::Text("%d", channel_stats[c]->invalid_pixels); break;
case 3: ImGui::Text("%d", channel_stats[c]->nan_pixels); break;
case 4:
default: ImGui::Text("%d", channel_stats[c]->inf_pixels); break;
}
}
}
Expand Down

0 comments on commit 725e025

Please sign in to comment.