Generate radial gradient based on blurred image - image-processing

I'm trying to find a way to calculate the gradient of a given image with a blurred overlay with a specific opacity on top. Here is an example :
This is the settings for the black overlay, background blur is set to 515px and color is black with 40% of opacity.
This is the based image (without the transparent black overlay)
And this is how it looks when both are layered, as you can see it looks like a gradient. What I'm trying to achieve is a similar gradient with similar color but I'm not sure which colors are used. I know I need to extract some colors from the based picture and used them to create multiple layers but because I don't understand what the blur exactly does I'm not sure what to do.


Metal - How to overlap textures based on color

I'm trying to use a render pass descriptor to draw two grayscale textures. I am drawing a black square first, then a light gray square after. The second square partially covers the first.
With this setup, the light gray square will always appear in front of the black square because it was drawn most recently in the render pass. However, I would like to know if there is a way to draw the black square above the light gray one based on its brightness. Since the squares only partially overlap is there a way to still have the black square appear on top simply because it has a darker pixel value?
Currently it looks something like this, where the gray square is drawn second so it appears on top.
What I would like is to be able to still draw the gray square second, but have it appear underneath based on the pixel brightness, like so:
I think MTLBlendOperationMin will do what you want:

How do I change colors below a level to transparency

I have an image with a black shape in the middle. The surrounding area is white with varying shades of gray speckles surrounding it. I used the Gimp eraser to remove most of the surrounding image. I did a color to alpha filter to the rest and it worked to 90%. When I export the work to a PNG I notice there is gradient noise / artifact in the png in the shape of what I left around the black shape with the erasure. It is a thin film of gray shading. How do I remove that last artifact of the shades of gray splotches?
Thank you.
Layer ➤ Mask ➤ Add layer mask, and initialize to Transfer layer's alpha channel
Start the Levels tool (which will act on the mask), and drag the leftmost handle in the "Input" area your grey shade disappears.
You can use the middle handle of the same area to adjust the pixellation of the edges.
When happy with the result use Layer ➤ Mask ➤ Apply layer mask.
But this problem stems from something you missed earlier. You should probably have removed another color in the color-to-alpha step. Or if there is a pattern in the background, you can try to replicate the complete pattern on an additional layer that you then put in "Color Erase" mode.

Chromatic filter openCV

I'm looking for a filter in openCV library that change the image chromatically. For example, the blur does not change the colors of the image, I need one that do it.
I got a colored image, I need to apply a filter that distorts the color. For example, if I have an image with a lot of blue, with this filter this blue will be less or more intensity.
My images are in L* a* b* colour space and I need to work in it.

Cocoa CoreGraphics: How to fill multiple shapes with a gradient

I have logo text drawn as shapes (closed CGBezierPaths) that I want to fill with a gradient.(Light at the top, moving to dark at the bottom) How can I fill each shape with gradient such that the gradient is the same color for each shape.
The problem is drawing the gradient for each shape, if the letters are different height then the gradient has a different ramp since the distance is smaller. Hope that makes sense.
So basically I want draw a single gradient down the rect and use all the shapes as a clipping mask. Is this possible?
For gradient drawing - take a look at this project:
It creates gradient using two colors programmatically.

How to overlay an picture with a given mask

I want to overlay an image in a given image. I have created a mask with an area, where I can put this picture:
Image Hosted by
The problem is, that the white area contains a black area, where I can't put objects.
How can I calculate efficiently where the subimage must to put on? I know about some functions like PointPolygonTest. But it takes very long.
The overlay image must put somewhere on the white place.
For example at the place from the blue rectangle.
Image Hosted by
If I understood correctly, you would like to put an image in a region (as big as the image) that is completely white in the mask.
In this case, in order to get valid regions, I would apply an erosion to the mask using a kernel of the same size as the image to be inserted. After erosion, all valid regions will be white.
The image you show however has no 200*200 regions that is entirely white, so I must have misunderstood...
But if you what to calculate the region with the least black in the mask, you could apply a blur instead of an erosion and look for the maximal intensity pixel in the blurred mask.
In both case you want to insert the sub-image so that its centre is on the position maximal intensity pixel of the eroded/blurred mask.
If you are interested in finding the region that would be the most distant from any black pixel to put the sub-image, you can define its centre as the maximal value of the distance transform of the mask.
Good luck,