Linear gradient with IPP functions
I would like to create linear gradient using IPP (Integrated Performance Primitives) functions and avoid pixel-by-pixel color manipulation.
In other words, I can't find appropriate function or combination of functions that wi开发者_开发问答ll alow me to create RGB image with gradient R0 to R1, G0 to G1, B0 to B1 (initial and final RGB values). I can create it manually by cycling each pixel and setting the color but I hope there is more elegant (and fast) way to do it.
The way I understand it, ippiImageRamp
can only create grey-value ramps, right?
Alternatively, you could use ippiResizeSqrPixel
to resize a 2x2 pixel image to full size with IPPI_INTER_LINEAR
interpolation:
RGB0 | RGB1
--------------- => [Full Sized Image]
RGB0 | RGB1
The result should be a linear gradient (although I never tried it). If you need a rotated gradient, you could use ippiWarpAffine
to scale and rotate at the same time.
I found some solution. With the help of ippiImageRamp function.
The function creates a one- or three-channel image that can be used as a test image to examine the effect of applying different image processing functions.
The destination image pixel values are computed according to one of the following formulas:
dst(x,y) = offset + slope * x, if axis = ippAxsHorizontal,
dst(x,y) = offset + slope * y, if axis = ippAxsVertical,
dst(x,y) = offset + slope * x * y, if axis = ippAxsBoth
精彩评论