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

Visualize sum of channels in widgets #598

Merged
merged 11 commits into from Jun 29, 2015

Conversation

Projects
None yet
3 participants
@nontas
Member

nontas commented Jun 26, 2015

Until now, when trying to visualize the sum of the channels of an image in visualize_images, we were using the glyph function with vectors_block_size=1.

This PR changes this and actually sums the image's channels. This is done by defining the sum_channels() method in menpo.visualize.image. The result is visually better and is also faster to compute.

nontas and others added some commits Jun 26, 2015

DOC FIX: User Guide update
Update the user guide and amend the documentation for the
channel flip.
@nontas

This comment has been minimized.

Member

nontas commented Jun 27, 2015

This is now ready. It can get in as soon as the tests pass!

if channels is None:
channels = range(pixels.shape[0])
# compute sum image
sum_image = np.sum(pixels[channels], axis=0)

This comment has been minimized.

@patricksnape

patricksnape Jun 29, 2015

Contributor

In the default case where no channels are chosen, this is twice as slow. Perhaps you should split the sum in to two between the two cases?

# compute sum image
sum_image = np.sum(pixels[channels], axis=0)
# return as c-contiguous
return np.ascontiguousarray(sum_image[None, ...]) # add a channel axis

This comment has been minimized.

@patricksnape

patricksnape Jun 29, 2015

Contributor

s.reshape((1,) + s.shape) does the same thing without requiring the copy. So you can remove the np.ascontiguousarray as well.

patricksnape added some commits Jun 29, 2015

Updates for sum_channels
Make the default sum, with all channels, faster by not performing
the indexing (roughly twice as fast).

Make adding the channels reshape free.
@patricksnape

This comment has been minimized.

Contributor

patricksnape commented Jun 29, 2015

Whoops, this also adds all the doc changes I did... but they aren't that important so we can just use this to pull them in as well

@jabooth

This comment has been minimized.

Member

jabooth commented Jun 29, 2015

@nontas is this ready?

@nontas

This comment has been minimized.

Member

nontas commented Jun 29, 2015

Yes! The methods glyph and sum_channels are now moved to menpo.feature.visualize and added to the docs. You can get it in if you're happy!

jabooth added a commit that referenced this pull request Jun 29, 2015

Merge pull request #598 from nontas/widget_sum
Visualize sum of channels in widgets

@jabooth jabooth merged commit e1ed845 into menpo:master Jun 29, 2015

3 checks passed

clahub All contributors have signed the Contributor License Agreement.
Details
continuous-integration/appveyor AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@jabooth jabooth removed the in progress label Jun 29, 2015

@jabooth jabooth deleted the nontas:widget_sum branch Jun 29, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment