Skip to content

Commit

Permalink
fix 0.5 pixel offset in rasterize_grains function
Browse files Browse the repository at this point in the history
  • Loading branch information
zsylvester committed Nov 19, 2024
1 parent 599a74d commit a99cafa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion segmenteverygrain/segmenteverygrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ def rasterize_grains(all_grains, image):
shapes_with_labels = zip(all_grains, labels)
# Define the shape and resolution of the rasterized output
out_shape = image.shape[:2] # Output array shape (height, width)
bounds = (0, image.shape[0], image.shape[1], 0) # Left, bottom, right, top of the array (bounding box)
bounds = (-0.5, image.shape[0]-0.5, image.shape[1]-0.5, -0.5) # Left, bottom, right, top of the array (bounding box)
# Define the transformation from pixel coordinates to spatial coordinates
transform = rasterio.transform.from_bounds(*bounds, out_shape[1], out_shape[0])
# Rasterize the polygons into an array of labels
Expand Down

0 comments on commit a99cafa

Please sign in to comment.