Skip to content

cv::distanceTransform() fail on a large image #12218

@hovnatan

Description

@hovnatan
  • OpenCV => 3.4.2
  • Operating System / Platform => Ubuntu 18.04
  • Compiler => gcc 8

Run

int main() {
  cv::Mat non_valid = cv::imread("surfaces_nonvalid.tif", cv::IMREAD_ANYDEPTH);
  cv::Mat dst;
  cv::Mat labels;
  cv::distanceTransform(non_valid, dst, labels, cv::DIST_L2, cv::DIST_MASK_3,
                        cv::DIST_LABEL_PIXEL);
  std::cout << labels.at<int>(0, 0) << std::endl; // <-- Error here: 0
  std::cout << labels.at<int>(50, 50) << std::endl; // <-- Error here: 0
  std::cout << labels.at<int>(5000, 5000) << std::endl; // Looks reasonable
  return 0;
}

on non_valid image from surfaces_nonvalid.zip. The labels output has a lot of erroneous zero label values on the left part of the output as seen on this screenshot (left image: input non_valid image, right image: output labels image. black pixels = 0):
screenshot from 2018-08-15 15-11-38

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions