How to blend 2 transparent triangles (DX11 or DX12) - directx-11

I need help with DirectX 11 or 12 to blend 2 transparent triangles as shown in the figure:
Fig 1 shows what I understand to be the blend of the 1st transparent triangle.
Fig 2 shows the blend of the 2nd transparent triangle (that is what I got so far).
But I want to achieve Fig 3. Is that possible?

Related

Morphological image processing

i am working on a project where i need to do some image processing, where i am not an expert.
I have an image obtained from QEMSCAN technology,as you can see here pink pixels represent the existence of the gold. there are 3 types of gold, type 1 where the connected pink pixels are surrounded with white ones. type 2 when the connected pink pixels are surrounded with white and another color.
type 3 where the pink area is connected with another colors except white.
I did some morphological image processing to isolate each area containing gold, but I'm blocked right now how i can determine to which type belong each pink area
thanks in advance
determine the type of gold
image
Here's a possible approach:
make all the pink pixels white and everything else black
do a dilation and find the coordinates of the additional pixels
check the colour(s) of the additional pixels in the original image

Threejs transparent materials union blending

I have two different objects with the same transparent material in threejs, and I want to blend them in a "non-additive" way like in the following picture. There are three boxes: one blue in the background and two transparent yellow boxes in the foreground. The left image is how it currently is, and the right image is what I want. Is there a kind of material / possibly shader that can achieve this effect?

Clipping or Erasing area in threejs

First I am explaining the above image. Image is marking with 1, 2 and 3.
1 - This is the rectangle shape.
2 - This is the rectangle shape.
3 - This is the circle shape (draw with destination-in global composite operation).
Every shape draw using HTML5 canvas.
Now I want to same draw using threejs with WebGLRenderer. So is it possible to draw? If yes then how?
3rd shape can be anything (for ex - circle, rectangle, polygon).
Any suggestion?
We can erase an area in threejs by set the blending property. In threejs different types of blending property available. For example THREE.SubtractiveBlending which is use to subtract the area.
For details -
1) http://threejs.org/docs/#Reference/Constants/Materials
2) http://threejs.org/examples/#webgl_materials_blending
3) http://threejs.org/examples/#webgl_materials_blending_custom
To draw using WebGLRenderer, is basically changing the canvas by:
renderer = new THREE.WebGLRenderer();
Just beware of the methods of Canvas that do not exist in WebGLRenderer.
If you show as part of the code, it would be good to give more precision. But anything, just comment here!

Determining rgb planes of a color image

What is meant by red,green or blue plane of a color image?How do we generate the red plane?how is it different from the other planes?Please explain the logic behind generating these planes?
Every pixel in a normal colour image is made up of a red part, a green part and a blue part - hence RGB image. Typically there is one byte for the red part at each location in the image, one for green and one for blue. As there is a byte for each pixel location, the red can vary between 0 (zero) which means "no red" and 255 which means "full red". Likewise the green and blue. So an image where all the pixels are
Red=255, Green=0, Blue=0 will look very bright red
Red=0, Green=255, Blue=0 will look very green
and a pixel where R=G=B will look grey, and if R=G=B=16 it will be very dark grey, and if R=G=B=240 it will be very light/bright grey.
So, the "red plane" is merely an image that only shows the red part of each pixel, or how much red there is in each pixel.
Here is a rose:
and here is the red plane, and you can see that where the rose is very red, the red plane is very bright meaning there is lots of red.:
Here is the green plane (you can see the green leaf on the right is bright):
and the blue plane (you can see the blueish petals on the left are bright):
If you want to separate the color channels (planes), it is very easy in ImageMagick to get the red plane, for example:
convert rose: -channel red -separate red.jpg
ImageMagick is free and amazing - available here.
Simple answer:
Say you read a 480x640 color image, like so:
A = imread('image.jpg');
The matrix A has dimensions 480 x 640 x 3. The third dimension are three 480 x 640 planes, or color channels:
red = A(:,:,1)
green = A(:,:,2)
blue = A(:,:,3)
Now you can go to the link #Trilarion gave in the comments and look at the portion about Truecolor Images.
If I understand your comment, you want to know how a CCD of a camera catch the chroma of each color.
Have a look to color space
And maybe about wavelength of colors (Look at the table of color frequency/wavelength for more informations)
And camera CDD to understand how camera catch those wavelenght and create color channel of an image.

Compositing layer styles

I am trying to implement "Inner shadow" style from Adobe Photoshop.
I have 3 RGBA layers: source layer (brown), inner shadow layer (white) and background layer. They can have Photoshop-like blend modes (Normal, Multiply, Color Burn ...) - blending is not associative!
I would like to blend them together like a layer style in Photoshop. When I multiply Shadow alpha by source alpha and blend (shadow Over (source Over background)), I am getting dark contours around the object, where source alpha is between 0 and 1.
Photoshop reference is on the left, my result is on the right.
The same problem would be with "Color overlay" and many other styles. Do you know how to do that correctly - avoid contours?
I found an answer to this problem in the specification of PDF format 1.7, at page 339.
So, compositing (shadow with (source with background)) is wrong. The right way to do it is:
Composite the source with background into temporary channels C, disregarding the source’s alpha and using alpha value of 1.0 everywhere.
Composite the (uncropped) shadow with C into C in standard way.
Compute a weighted average of C with the background into background, using the source alpha
as the weighting factor.
As you see, shadow was blended both with source and background. Weighted average was the function I was looking for.

Resources