Skip to content

Enable rescaling when resample=False#1434

Closed
jeskowagner wants to merge 1 commit intoMouseLand:mainfrom
jeskowagner:main
Closed

Enable rescaling when resample=False#1434
jeskowagner wants to merge 1 commit intoMouseLand:mainfrom
jeskowagner:main

Conversation

@jeskowagner
Copy link
Copy Markdown

I think there was some back and forth about the interaction of diameter, resample and the resize-ing happening under the hood. This meant that masks are sometimes returned with dimensions different to the input.

import cellpose
import cellpose.models
import numpy as np

img = np.random.rand(100,100)
model = cellpose.models.CellposeModel()

masks, _, _ = model.eval(img, diameter=10, resample=False)
print(masks.shape)
#> (300, 300) # <- this is the issue

# When using resample=True the dimensions are as expected
masks, _, _ = model.eval(img, diameter=10, resample=True)
print(masks.shape)
#> (100, 100)

Otherwise returned masks are larger than input image
@mrariden
Copy link
Copy Markdown
Collaborator

mrariden commented Apr 28, 2026

Thanks @jeskowagner for pointing this out. The fix is in dynamics.py:resize_and_compute_masks() which I implemented in #1438

@mrariden mrariden closed this Apr 28, 2026
boring-repos Bot pushed a commit to harryzcy/cellpose that referenced this pull request May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants