Repository navigation
RGB to/from Gray rewritten to wide intrinsics - #13379
Merged
Merged
Conversation
alalek
approved these changes
Dec 7, 2018
| #if CV_SIMD | ||
| const int vsize = v_uint8::nlanes; | ||
| v_uint8 vz = vx_setzero_u8(), vn0 = vx_setall_u8(255); | ||
| for(; i < n-vsize+1; |
Member
There was a problem hiding this comment.
i < n-vsize+1
Other code uses this form for vectorized loops:
i <= n - vsize
terfendail
reviewed
Dec 11, 2018
|
|
||
| if( gb == 6 ) | ||
| { | ||
| g0 = ((t0 >> 5) << 10) >> 8; |
Contributor
There was a problem hiding this comment.
Wouldn't one bit-mask be faster than two shifts?
Contributor
Author
There was a problem hiding this comment.
I did exactly that in the beginng then decided to use shifts instead since masking requres one extra register for mask.
Can't figure out which code works faster. Their performance differs less than between any two runs of identical code.
Contributor
Author
|
@alalek ARM builds fixed |
Merged
SavyaSanchi-Sharma
pushed a commit
to SavyaSanchi-Sharma/opencv
that referenced
this pull request
Jul 30, 2026
RGB to/from Gray rewritten to wide intrinsics (opencv#13379) * 5x5 to RGB added * RGB25x5 added * Gray2RGB added * Gray2RGB5x5 added * vx_set moved out of loops * RGB5x52Gray added * RGB2Gray written * warnings fixed (int -> (u)short conversion) * warning fixed * warning fixed * "i < n-vsize+1" to "i <= n-vsize" * RGBA2mRGBA vectorized * try to fix ARM builds * fixed ARM build for RGB2RGB5x5 * mRGBA2RGBA: saturation, vectorization * fixed CL implementation of mRGBA2RGBA (saturation added)
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.
Merge with extra: opencv/opencv_extra#560
This pullrequest changes
color_rgb.cpprewritten to wide universal intrinsicsmRGBA2RGBA: saturation addedmaster branch has different RGB2Gray coefficients so there will be separate PR
Performance
Baseline AVX2
Baseline AVX512SKX
Baseline SSE2
Baseline SSE4.1
Not covered
Several conversions are not covered by perf tests so their performance was estimated with custom test: random image 511x511, time measured by loop of 20000 identical calls, averaged by 5 runs.Resulting improvement depends on baseline and number of channels but doesn't differ significantly:
RGB2Gray<float>:RGB5x52Gray:RGB2Gray<ushort>:RGBA2mRGBA<uchar>:*
mRGBA2RGBA<uchar>: