Skip to content

Divide by zero error in SEEDS Superpixels #2935 #2937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/ximgproc/src/seeds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ class SuperpixelSEEDSImpl : public SuperpixelSEEDS
//compute initial label for sublevels: level <= seeds_top_level
//this is an equally sized grid with size nr_h[level]*nr_w[level]
int computeLabel(int level, int x, int y) {
return std::min(y / (height / nr_wh[2 * level + 1]), nr_wh[2 * level + 1] - 1) * nr_wh[2 * level]
+ std::min((x / (width / nr_wh[2 * level])), nr_wh[2 * level] - 1);
return std::min(y * nr_wh[2 * level + 1] / height, nr_wh[2 * level + 1] - 1) * nr_wh[2 * level]
+ std::min(x * nr_wh[2 * level] / width, nr_wh[2 * level] - 1);
}
inline int nrLabels(int level) const {
return nr_wh[2 * level + 1] * nr_wh[2 * level];
Expand Down