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

ElasticTransformation incorrect filling new pixels #561

Merged
merged 1 commit into from
Jan 11, 2020

Conversation

apatsekin
Copy link
Contributor

For all other geometric augmentations, when applied to 3-channel pictures cval value interpreted as (cval,cval,cval), so you can set either black/gray/white filling of emerged pixels. However, for Elastic Transformation setting cval=255 leads to red pixels. That is happening because cv2.remap takes RGB tuple for 3-channel images for borderValue. If integer passed, it is used as (cval,0,0), hence producing red pixels.

I'm not sure this is correct way to fix this issue, but at least on my setup it works.

For all other geometric augmentations, when applied to 3-channel pictures `cval` value interpreted as (cval,cval,cval), so you can set either black/gray/white filling of emerged pixels. However, for Elastic Transformation setting `cval=255` leads to red pixels. That is happening because cv2.remap takes RGB tuple for 3-channel images for `borderValue`. If integer passed, it is used as (cval,0,0), hence producing red pixels. 

I'm not sure this is correct way to fix this issue, but at least on my setup it works.
@codecov-io
Copy link

codecov-io commented Jan 11, 2020

Codecov Report

Merging #561 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #561      +/-   ##
==========================================
- Coverage   96.43%   96.42%   -0.01%     
==========================================
  Files          38       38              
  Lines       13933    13933              
==========================================
- Hits        13436    13434       -2     
- Misses        497      499       +2

@aleju
Copy link
Owner

aleju commented Jan 11, 2020

Nice, thanks a lot for pointing this one out. There were tests for the cval in ElasticTransformation, but they all operated with (H, W) images instead of (H, W, 3), so this wasn't caught.

The way it is implemented should be good for now. The cval should probably be sampled channelwise at some point so that e.g. RGB values and not just intensity values are possible. But that can be reserved for a follow-up patch.

@aleju aleju merged commit 8f5dcd4 into aleju:master Jan 11, 2020
@aleju
Copy link
Owner

aleju commented Jan 11, 2020

Merged.

aleju added a commit that referenced this pull request Jan 11, 2020
This is a follow-up patch for PR #561, which
fixed that new pixels were filled by
ElasticTransformation with `(cval, 0, 0)`
instead of `(cval, cval, cval)`.

This patch adds a corresponding changelog
entry and test case.
aleju added a commit that referenced this pull request Jan 11, 2020
Follow-up on PR #561 (test, changelog entry)
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.

3 participants