gradient

Function to compute 3D gradient with unevenly spaced sample locations

不羁岁月 提交于 2019-12-04 17:04:06
I have experimental observations in a volume: import numpy as np # observations are not uniformly spaced x = np.random.normal(0, 1, 10) y = np.random.normal(5, 2, 10) z = np.random.normal(10, 3, 10) xx, yy, zz = np.meshgrid(x, y, z, indexing='ij') # fake temperatures at those coords tt = xx*2 + yy*2 + zz*2 # sample distances dx = np.diff(x) dy = np.diff(y) dz = np.diff(z) grad = np.gradient(tt, [dx, dy, dz]) # returns error This gives me the error: ValueError: operands could not be broadcast together with shapes (10,10,10) (3,9) (10,10,10) . EDIT: according to @jay-kominek in the comments

smooth gradient on different devices

混江龙づ霸主 提交于 2019-12-04 16:26:52
问题 In my app i have gradient as drawable which i am using as background and i wan't it to make it look as smooth as possible. After googling and trying by myself i came up with the following. On nexus one if you call only setDither(true) your gradient is still banding so you have to set PixelFormat like this Window.setFormat(PixelFormat.RGBA_8888). But on the other side G1 does not support RGBA_8888 so calling it make the gradient even uglier than before so Window.setFormat(PixelFormat.RGBA_8888

WPF 3D - mapping gradient brush on complex geometry

前提是你 提交于 2019-12-04 16:02:45
I wanted to ask if anyone knows how to map gradient brush on complex objects in WPF 3D. The result should look similar to 3D images in matlab (3D function for example). Lets say you have some 3-dimensional data you wish to visualize and you want to diferentiate certain levels of values by color. Given a GradientBrush defined something like this: <LinearGradientBrush x:Name="RedYellowGradient"> <GradientStop Color="Blue" Offset="0.01" /> <GradientStop Color="Purple" Offset="0.25"/> <GradientStop Color="Red" Offset="0.5"/> <GradientStop Color="Orange" Offset="0.75"/> <GradientStop Color="Yellow"

Is it possible to set horizontal gradient to text via CSS? (left letter one colour, right - another colour) [duplicate]

非 Y 不嫁゛ 提交于 2019-12-04 14:54:21
This question already has an answer here: css text gradient 4 answers Is it possible to set horizontal gradient to text via CSS? (left letter one colour, right - another colour). Yes, it is. h1 { font-size: 72px; background: -webkit-linear-gradient(left, red , yellow); background: -o-linear-gradient(right, red, yellow); background: -moz-linear-gradient(right, red, yellow); background: linear-gradient(to right, red , yellow); -webkit-background-clip: text; -webkit-text-fill-color: transparent; } <h1>Hello World</h1> 来源: https://stackoverflow.com/questions/39884260/is-it-possible-to-set

Plotting a Gradient Vector Field in OpenCV

二次信任 提交于 2019-12-04 13:31:27
问题 I want to compute the gradient of a gray-scale image ( smoothed_plane in the code) and plot it as a vector field in OpenCV, superposed to an existing image. I tried to apply a pair of Sobel operators (I also tried Scharr) to compute the two derivatives along x and y as described in OpenCV documentation, but when I try to plot, the vector field seems to be completely wrong. I would like to understand what is my mistake. I put some code here to be more clear. Thanks in advance for your help. /

Modern technique of adding gradient to UIView

瘦欲@ 提交于 2019-12-04 12:44:45
I know of several ways of adding background gradients to UIView. I was wondering what is the most efficient and scalable way of doing so, and why? Here are the techniques I've used: Create subview of UIView and overwrite the drawRect, where I draw the gradient in current context. a. When using the above gradient create it with the bounds of view I want to decorate and insert this background gradient as first subview, i.e. – insertSubview:atIndex: b. After I get the background gradient view from above, I render it in image context and use it as background image, i.e. UIGraphicsBeginImageContext

Gradient calculation with python

耗尽温柔 提交于 2019-12-04 12:28:45
问题 I would like to know how does numpy.gradient work. I used gradient to try to calculate group velocity (group velocity of a wave packet is the derivative of frequencies respect to wavenumbers, not a group of velocities). I fed a 3 column array to it, the first 2 colums are x and y coords, the third column is the frequency of that point (x,y). I need to calculate gradient and I did expect a 2d vector, being gradient definition df/dx*i+df/dy*j+df/dz*k and my function only a function of x and y i

Is there a way to draw a CGContextDrawRadialGradient as an oval instead of a perfect circle?

僤鯓⒐⒋嵵緔 提交于 2019-12-04 11:51:48
问题 I need a radial gradient in the shape of an oval or ellipse and it seems like it CGContextDrawRadialGradient can only draw a perfect circle. I've been drawing to a square context then copying/drawing into a rectangular context. Any better way to do this? Thanks! 回答1: The only way I've found to do this is as Mark F suggested, but I think the answer needs an example to be easier to understand. Draw an elliptical gradient in a view in iOS (and using ARC): - (void)drawRect:(CGRect)rect {

How to implement a conical/cone/circular gradient in WPF

馋奶兔 提交于 2019-12-04 11:32:25
I would like to recreate a conical/circular gradient in WPF. I've looked into inheriting System.Windows.Media.GradientBrush - which can be inherited from - but uses a lot of internal plumbing to get the job done (inherited from System.Windows.Media.Brush) Any ideas on how to achieve this would be appreciated (preferrably without resorting to bitmaps) Cheers. Dan This question was asked some time back in July ( Circular Gradient and WPF ) but I didn't want to resurrect an old question. You could create a custom Effect. I would recommend downloading Shazzam you will also need the DirectX SDK.

How to create multiple stop gradient fragment shader?

老子叫甜甜 提交于 2019-12-04 11:22:03
问题 I'm trying to create an OpenGL ES 2.0 fragment shader that outputs multiple stop gradient along one axis. It should interpolate between multiple colors at points defined in percents. I've achieved this by using if s the fragment shader, like this: float y = gl_FragCoord.y; float step1 = resolution.y * 0.20; float step2 = resolution.y * 0.50; if (y < step1) { color = white; } else if (y < step2) { float x = smoothstep(step1, step2, y); color = mix(white, red, x); } else { float x = smoothstep