I need to replicate a circular (or angle) gradient from a Photoshop comp in WPF; so far I can only find linear and radial. Does anyone know if such a thing exists, or and easy way to get get a circular gradient in WPF?
Note: I'm not asking about a radial gradient. A circular gradient is like taking a rectangle, applying a gradient and then transforming the rectangle into a circle.
Check this question for a new and a bit more complete answer to this question.
While I've never done this before (so I don't know what's involved) you could implement a type that inherits from GradientBrush. I don't think this is trivial though.
I've also not worked with Photoshop circular gradients, but from your description I can't help but think that you could at least approximate it using a LinearGradientBrush and then transforming the result - perhaps using a MatrixTransform.
Sorry that I can't give you concrete answers, but maybe these suggestions can point you in the right direction.
Related
I can't find a working example of a cutting plane implementation for HelixToolkit.Wpf.SharpDX.
I hope to achieve something simpler than the HelixToolkit.Wpf cutting plane which can be invoqued by shift+clic anywhere on the displayed model.
I'll be happy if at least I would be able to do cutting planes with axis-oriented normals, I don't have any interest in custom oriented cutting planes.
Edit
After answering to first comment, I add the precision about trying to do something after the CrossPlaneSection example from the github, but couldn't find someting to use on a more complicated scene. Still waiting for tips.
See the cross section example in Sharpdx version
https://github.com/helix-toolkit/helix-toolkit/tree/develop/Source/Examples/WPF.SharpDX/CrossSectionDemo
i am using linear gradient horizontal. I want to use more of the starting gradient color than ending one. Presently both color have equal proportion ie meet in the center. How can i get more of one color than the other? Also i came to know that setBackgroundGradientRelativeX etc method only applies to radial gradient not linear one. Moreover i have lots of various simple gradients in the designs, so i dont want to use images everywhere. It would be troublesome.
categoryTitle.setUIID("partyCategoryTitle");
categoryTitle.getAllStyles().setBackgroundGradientStartColor(0x73a0ff);
categoryTitle.getAllStyles().setBgImage(null);
categoryTitle.getAllStyles().setBackgroundGradientEndColor(0xffffff);
categoryTitle.getAllStyles().setBackgroundGradientRelativeX(1);
categoryTitle.getAllStyles().setBackgroundGradientRelativeY(10);
categoryTitle.getAllStyles().setBackgroundType(Style.BACKGROUND_GRADIENT_LINEAR_HORIZONTAL);
As gradients currently don't really work on Android I'd avoid it.
I can't stress enough how badly gradients perform in the current implementation when they do work. Adding features to something that isn't working properly at this time is not a priority.
I'm currently looking to achieve a gradient effect a bit like the rectangle in http://pjnicholson.com/Fireworks/fillgradients.htm
If I compromise a little I can get close to this using RadialGradientBrush... but is there any (not too painful) way to achieve the rectangular effect?
Use an ImageBrush instead and use this image (or a similar image generated using some image editor) for the background of your rectangle.
One solution a colleague and I came with was to derive a new Panel that used a WriteableBitmap as the source for its background.
The panel will give you the dimensions you need to make your WriteableBitmap. Using whatever algorithm you want you can fill it appropriately. In our case, we needed a radial or cone gradient, but the same concept applies.
Additionally, you can create several properties on your new control to specify the colors for the gradient. We adapted a LinearGradientBrush for our needs, but if you're working on just two colors, simple properties may suffice.
I don't have the code handy but will try to find it and post an update later. But the above should get you going.
I have a sequence of images taken from a camera. The images consists of hand and surroundings. I need to remove everything except the hand.
I am new to Image processing. Would anyone help me in regard with the above Question. I am comfortable using C and Matlab.
A really simple approach if you have a stationary background and a moving hand (and quite a few images!) is simply to take the average of the set of images away from each image. If nothing else, it's a gentle introduction to Matlab.
The name of the problem you are trying to solve is "Image Segmentation". The Wikipedia page here: wiki is a good start.
If lighting consistency isn't a problem for you, I'd suggest starting with simple RGB thresholding and see how far that gets you before trying anything more complicated.
Have a look at OpenCV, a FOSS library for computer vision applications. Specifically, see the Video Surveillance module. For a walk through of background subtraction in MATLAB, see this EETimes article.
Can you specify what kind of images you have. Is the background moving or static? For a static background it is a bit straightforward. You simply need to subtract the incoming image from the background image. You can use some morphological operations to make it look better. They all depend on the quality of images that you have. If you have moving background I would suggest you go for color based segmentation. Convert the image to YCbCr then threshold appropriately. I know there are some papers available on it(However I dont have time to locate them). I suggest reading them first. Here is one link which might help you. Read the skin segmentation part.
http://www.stanford.edu/class/ee368/Project_03/Project/reports/ee368group08.pdf
background subtraction is simple to implement (estimate background as average of all frames, then subtract each frame from background and threshold resulting absolute difference) but unfortunately only works well if 1. camera has manual gain and exposure 2. lighting conditions do not change 3.background is stationary. 4. the background is visible for much longer than the foreground.
given your description i assume these are not the case - so what you can use - as already pointed out - is colour as a means of segmenting foreground from background. as it's a hand you are trying to isolate best bet is to learn the hand colour. opencv provides some means of doing this. if you want to do this yourself you just get the colour of some of the hand pixels (you would need to specify this manually for at least one frame) and convert them to HUE (which encapsulates the colour in a brightness independen way. skin colour has a very constant hue) and then make a HUE histogram. compare this to the rest of the pixels and then decided if the hue is simmilar enough.
I am trying to implement an effect that will stretch a polygon along a line from its center point to the mouse location. I've tried various approaches with a SkewTransform and the planar angle between those two points but that isn't giving me what I want.
I am kind of assuming I'll have to go the MatrixTransform route but my linear algebra is pretty rusty.
You can either use the ScaleTransform and just apply it in one direction then combine it with a RotateTransform if the direction you need to stretch in isn't just plain x or y, or take a look at the Stretch property on the shape.
There's a good article on CodeProject that has some examples.
MSDN also has some reference material.