Repository navigation
BUG: pad_image and decrop_image failed on multichannel images - #965
Open
Srizdebnath wants to merge 1 commit into
Open
Srizdebnath wants to merge 1 commit into
Srizdebnath wants to merge 1 commit into
Conversation
crop_image and crop_indices split multichannel images into channels, but pad_image and decrop_image passed the vector image straight to the scalar-only padImage/cropImage bindings and raised a nanobind TypeError. Process each channel and merge the result, keeping channels_first. decrop_image pastes each cropped channel into the matching channel of full_image, or into full_image itself when it is scalar.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
crop_imageandcrop_indicesaccept multichannel images: they split the channels, crop each one and merge them. Two related functions don't:The
cropImageandpadImagebindings only exist for scalar images, and these two functions pass the vector image straight through. As a result, a multichannel crop can't be put back withdecrop_image. Neither works on, say, an RGB image or a multi-component derived image, and neither do functions built onpad_image.This uses the same split, process and merge pattern as
crop_image, and keepschannels_first:pad_imagepads every channel with the same widths. Withreturn_padvals=Trueit still returns(image, lower, upper).decrop_imagepastes each cropped channel into the matching channel offull_image, or intofull_imageitself when that is a scalar image. A channel-count mismatch raises aValueError.test_decrop_image_multichannelandtest_pad_image_multichannelcheck each output channel against the scalar function applied to that channel. They fail onmainand pass here, and the existing crop and pad tests still pass.