VTK: setting transparent renderer background - transparency

I am allowed to define the backgroundColor of a renderer by calling
renderer = vtk.vtkRenderer()
renderer.SetBackground(0,255,0)
[![enter image description here][1]][1]
My question:
Is it possible to set the opacity of the background ?
You can see my problem (with multiple viewports) in my example image. I could get rid of this "cutting" by simply using transparent backgrounds...
thanks in advance!

I finally found a solution :
you can set a layer for each renderer. Default is Layer 0 (not transparent). Everything greater than layer 0 will be transparent. But keep in mind to set at least a empty renderer (no volume or object) with a background-color on layer 0 to avoid ugly reflections.
renderer.SetBackground(255,255,255)
renderer.SetLayer(0)
# transparency layer
renderer.SetLayer(1)
renderer.addVolume(....)
Result:

For those who want to use transparency in a screenshot.
render_window = vtk.vtkRenderWindow()
render_window.AddRenderer(renderer)
render_window.SetAlphaBitPlanes(1) # Enable usage of alpha channel
...
w2if = vtk.vtkWindowToImageFilter()
w2if.SetInput(render_win)
w2if.SetInputBufferTypeToRGBA() # Also record the alpha (transparency) channel
...
More details in this official vtk example.
Edit: In addition, if the above is not working (e.g. the background is transparent but the actors are white/not rendered properly), you can try to enable depth peeling.
Before the above code snippet you should add
# the renderer, as in the question
renderer = vtk.vtkRenderer()
renderer.AddActor(actor)
renderer.SetBackground(0,255,0)
renderer.SetBackgroundAlpha(0.2) # add background opacity value
renderer.SetUseDepthPeeling(1) # only works with current GPUs
renderer.SetOcclusionRatio(0.2) # 0. is better, but much slower
You might also need to increase the maximum number of peels (default is 4). Check this VTK Wiki page for more details.

for set background on vtkFullScreenRenderWindow function,
you can use the File to find your ideal color.

Related

OpenCV Separate background and foreground of an image based on red and green marker

I just start exploring computer-vision field and I'm trying to create something like this (this image is what I'm trying to achieve not what I've already achieve)
My approach is (just a logical solution, havent try it yet):
Color detection.
First, get pixel position of lines with red and green color then add all that value to arrayRed and arrayGreen.
Segmentation
Get base image from cache then get all pixel with value that close to arrayRed and label it as label background. Do the same for arrayGreen
Convert color space to RGBA and set the Alpha of label background to 0
My question :
Am I on the right path?
Is this possible to achieve with OpenCV library?
If my approach is wrong, what's the efficient and actually right approach(in pseudo-code or python) to achieve the goal?

Adding border to edges of opaque area of UIImage with a filter

Hello: Currently in my project, I'm using OBShapedButton to process touches on a lot of objects that overlap (it's a map with each territory its own separate object). Basically, this library prevents a touch from being processed on a transparent point on the given view.
I'm attempting to add a border effect to just the edges of the opaque part of the UIImage (and adding a semi-transparent overlay above that). Something to the effect of this:
Which can be simplified to this (example of one image):
I am currently using MGImageUtilities to color in the opaque parts of territories using this line:
[territory setImage:[[territory image] imageTintedWithColor:tint]];
The problem is that I'm not sure how to just color the borders (which can be any shape). I've looked at this link already, but haven't been able to come up with anything.
Thanks in advance for the help!
Terribly hacky, but use MGImageUtilities' UIImage+ProportionalFill with scale resizing to create a slightly larger image, UIImage+Tint to red, and stack below.
The library you are using doesn't actually specify a shape layer. It uses alpha values from the PNGs that you give it.
Could you use a different 'highlighted' or 'selected' PNG that adds the border effect you are looking for?
Otherwise, it you will have to generate a UIBezierPath from your PNG image, which sounds like a very computationally intensive operation. At that point, I might question whether this library meets your needs.

How to apply chroma key filter with any color to live camera feed ios?

Basically I want to apply chroma key filter to ios live camera feed but I want user to pick the color which will be replaced by another color.
I found some examples using green screen but I don't know how to replace color dynamically instead of just green color.
Any idea how can I achieve that with best performance?
You've previously asked about my GPUImage framework, so I assume that you're familiar with it. Within that framework are two filters, a GPUImageChromaKeyFilter and a GPUImageChromaKeyBlendFilter. Both will key off of whatever color you specify via the -setColorToReplaceRed:green:blue: method, with a threshold set using the thresholdSensitivity property.
The former filter merely turns areas matching the color within the threshold to an alpha of 0, with the latter actually doing a blend against another image or video source based areas of the input image or video that match. The FilterShowcase example application shows how to do this for green, but you can set the keying color to anything you want.

XNA How To Make Transparent Texture

I read and try that pure Magenta Color 255, 0, 255 in an image is automatically transparent, but unfortunately failed, is there anything should I setup first?
Also I read and try include alpha in a PNG Image, the strange is when I used it on a project it's work, but not on the other, what is likely wrong with the code?
Please kindly reply, thank you
For Magenta to be transparent, look at the properties of your image file. Right click in solution explorer, properties.
There is an option there to specify the transparent color to be used (magenta by default).
Then, there is the rendering to consider. How are you drawing your texture? With SpriteBatch, it is automatic, but you may have sorting issues. Check the order in which you draw your textures and the SpriteSortMode.

How to use ImageMagick to substract a image from another?

I have this two images :
(source: free.fr)
(source: free.fr)
How can I use imagemagick to remove the background (second picture) from the first one ?
Cheers,
Rémy
Here I made you a final but simple example :
Transparent Overlay http://noosphere.ionyse.com/transparent_example/transparent_difference.png
Background http://noosphere.ionyse.com/transparent_example/background.png
Example 1 http://noosphere.ionyse.com/transparent_example/background-example.png
Example 2 http://noosphere.ionyse.com/transparent_example/background-example2.png
Here you see that anywhere I put the transparent overlay on the background I get the perfect match using the opacity of the overlay PNG.
I would like to be able to calculate this overlay image. Do you think it is possible using ImageMagick ?
This is explained over here How to save the DIFFERENCES between two images ?.
Another useful link: http://www.imagemagick.org/Usage/compare/#difference

Resources