Skip to content

Add column / row wise normalization to imshow and pyrshow#49

Open
ershook wants to merge 1 commit intoLabForComputationalVision:mainfrom
ershook:row_col_vrange
Open

Add column / row wise normalization to imshow and pyrshow#49
ershook wants to merge 1 commit intoLabForComputationalVision:mainfrom
ershook:row_col_vrange

Conversation

@ershook
Copy link
Copy Markdown

@ershook ershook commented May 1, 2026

This PR:

  • Adds column and row wise normalization to imshow and pyrshow.
  • Tests that figure titles match vmin/vmax of displayed images.
  • Tests that vmin/vmax of displayed images matches expected values.

Copy link
Copy Markdown
Member

@billbrod billbrod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting this together Erica! I don't have time to do a full review right now, so I've added some small comments and will get back to this in more detail tomorrow.

Comment thread TESTS/unitTests.py
Comment on lines +1489 to +1495
def _get_clims(fig):
"""get vmin vmax for each image in fig as list of tuples (vmin, vmax)"""
return [ax.images[0].get_clim() for ax in fig.axes if ax.images]

# define test images such that each image has a different range of values,
# so we can test that the correct vrange is applied to each one
IMAGES = [np.arange(4 * i, 4 * i + 4, dtype=float).reshape(2, 2) for i in range(4)]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are only used by TestVrange, right? they should be moved within that class

Comment thread TESTS/unitTests.py
with self.subTest(mode=mode, img_idx=img_idx):
fig = self._imshow(f"auto{mode}")
clim_vmin, clim_vmax = _get_clims(fig)[img_idx]
title_vmin, title_vmax = _get_title_clims(fig)[img_idx]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the function _get_title_clims is missing, so all tests fail when I run this locally. can you add it?

If a 2-tuple, specifies the image values vmin/vmax that are mapped to
(ie. clipped to) the minimum and maximum value of the colormap,
respectively.
If a list of 2-tuples, the length of number of images, each image has an
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the indent here is wrong to make the docs render correctly (and some of that is our fault predating your PR, but we may as well fix it all now). Can you reformat this (and the corresponding docstrings in imshow, pyrshow, animshow) look like this? (you can also see it in the corresponding docstring from plenoptic)

Image



def colormap_range(image, vrange='indep1', cmap=None):
def colormap_range(image, vrange= 'indep1', cmap=None, n_rows = None, n_cols = None):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add sections to Arguments documenting n_rows, n_cols

also, and this is a pre-existing issue, can you add one for cmap? something like:

    cmap : matplotlib colormap, optional
        colormap to use when showing these images. If None, will pick RdBu_r if vrange is some variant of auto0 or indep0, else will pick gray.

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