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

Allow fill mosaic blank pixels with specified value #141

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 7 additions & 1 deletion ashlar/reg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1065,10 +1065,12 @@ def _load_correction_profiles(self, dfp_path, ffp_path):
self.dfp /= np.iinfo(self.dtype).max
self.do_correction = True

def assemble_channel(self, channel, out=None):
def assemble_channel(self, channel, out=None, fill_blank_value=None):
num_tiles = len(self.aligner.positions)
if out is None:
out = np.zeros(self.shape, self.dtype)
if fill_blank_value is not None:
mask = np.ones(self.shape, bool)
else:
if out.shape != self.shape:
raise ValueError(
Expand All @@ -1082,6 +1084,10 @@ def assemble_channel(self, channel, out=None):
img = self.aligner.reader.read(c=channel, series=si)
img = self.correct_illumination(img, channel)
utils.paste(out, img, position, func=utils.pastefunc_blend)
if fill_blank_value is not None:
utils.paste(mask, np.zeros_like(img, bool), position)
if fill_blank_value is not None:
out[mask] = fill_blank_value
# Memory-conserving axis flips.
if self.flip_mosaic_x:
for i in range(len(out)):
Expand Down