Skip to content
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

Fix bug in local Euclidean distance calculation for fast implementation #41

Merged
merged 3 commits into from
Feb 20, 2023
Merged
Show file tree
Hide file tree
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 FastGeodis/fastgeodis.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ torch::Tensor generalised_geodesic2d_cuda(
torch::Tensor generalised_geodesic3d_cuda(
const torch::Tensor &image,
const torch::Tensor &mask,
const std::vector<float> &spacing,
std::vector<float> spacing,
const float &v,
const float &l_grad,
const float &l_eucl,
Expand All @@ -64,7 +64,7 @@ torch::Tensor generalised_geodesic2d_cpu(
torch::Tensor generalised_geodesic3d_cpu(
const torch::Tensor &image,
const torch::Tensor &mask,
const std::vector<float> &spacing,
std::vector<float> spacing,
const float &v,
const float &l_grad,
const float &l_eucl,
Expand Down
7 changes: 5 additions & 2 deletions FastGeodis/fastgeodis_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ void geodesic_frontback_pass_cpu(
ld += float(std::abs(h_i - 1)) * spacing[1];
ld += float(std::abs(w_i - 1)) * spacing[2];

local_dist[h_i * 3 + w_i] = ld;
local_dist[h_i * 3 + w_i] = sqrt(ld);
}
}

Expand Down Expand Up @@ -342,13 +342,16 @@ void geodesic_frontback_pass_cpu(
torch::Tensor generalised_geodesic3d_cpu(
const torch::Tensor &image,
const torch::Tensor &mask,
const std::vector<float> &spacing,
std::vector<float> spacing,
const float &v,
const float &l_grad,
const float &l_eucl,
const int &iterations
)
{
// square spacing with transform
std::transform(spacing.begin(), spacing.end(), spacing.begin(), spacing.begin(), std::multiplies<float>());

torch::Tensor image_local = image.clone();
torch::Tensor distance = v * mask.clone();

Expand Down
7 changes: 5 additions & 2 deletions FastGeodis/fastgeodis_cuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ void geodesic_frontback_pass_cuda(
ld += float(std::abs(h_i - 1)) * spacing[1];
ld += float(std::abs(w_i - 1)) * spacing[2];

local_dist[h_i * 3 + w_i] = ld;
local_dist[h_i * 3 + w_i] = sqrt(ld);
}
}
// copy local distances to GPU __constant__ memory
Expand Down Expand Up @@ -582,13 +582,16 @@ void geodesic_frontback_pass_cuda(
torch::Tensor generalised_geodesic3d_cuda(
const torch::Tensor &image,
const torch::Tensor &mask,
const std::vector<float> &spacing,
std::vector<float> spacing,
const float &v,
const float &l_grad,
const float &l_eucl,
const int &iterations
)
{
// square spacing with transform
std::transform(spacing.begin(), spacing.end(), spacing.begin(), spacing.begin(), std::multiplies<float>());

torch::Tensor image_local = image.clone();
torch::Tensor distance = v * mask.clone();

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ def get_extensions():

setup(
name="FastGeodis",
version="1.0.0",
version="1.0.1",
description="Fast Implementation of Generalised Geodesic Distance Transform for CPU (OpenMP) and GPU (CUDA)",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/masadcv/FastGeodis",
author="Muhammad Asad",
author_email="[email protected]",
author_email="[email protected]",
license="BSD-3-Clause License",
classifiers=[
"License :: OSI Approved :: BSD License",
Expand Down