How do I change colors below a level to transparency - 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.

Related

Generate radial gradient based on blurred image

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: https://developer.apple.com/documentation/metal/mtlblendoperation/mtlblendoperationmin?language=objc

android: smooth out edges of random shape bitmap

I have an random shape bitmap cut out by user. I want to fade out its borders i.e. contours, so as to make it appear smooth. What should I do? To get the borders and color of every pixel in bitmap, I am traversing it pixel by pixel. It takes long time, still I am ok with it. Is openCV my only option? If yes, can anybody point me towards any tutorial or suggestion for logical approach?
You can just run a smoothing filter on your shape.
In opencv you can use the blur fnnction or gaussainBlur. Look at http://docs.opencv.org/2.4/doc/tutorials/imgproc/gausian_median_blur_bilateral_filter/gausian_median_blur_bilateral_filter.html.
You don't have to use opencv but i think it would be easier and faster.
If you still don't want can use any other code that implement smoothing an image.
In case you just want to effect the border pixels do the following:
Make a copy of the original image
Filter the entire image.
Extract the border pixel using opencv findContours.
Copy from the blurred image only the pixels in the border and in there neighborhood and copy them to the copy you did in step 1.

Line detection against darker shades

I wants to detect lines from an image with black line drawing over white papers.
It could be easy if its ideal 'black and white', using histogram threshold would do.
But, as the image attached shows, some lines (e.g. in the light red circle) are in gray lighter than the shades (e.g. in the dark red circle). So some shades are obtained before light lines using histogram threshold.
Is there any ideas to divide lines from shades with some 'knowledge'? Thanks!
Edit:
Here are the raw images, a bit small because they are of original resolution.
Thanks :-)
I would add another method using Gaussian blur other than erosion+dilation, for your reference:
file='http://i.stack.imgur.com/oEjtT.png';
I=imread(file);
h = fspecial('gaussian',5,4);
I1=imfilter(I,h,'replicate');
h = fspecial('gaussian',5);
I2=imfilter(I,h,'replicate');
I3=I1-I2;
I3=double(I3(:,:,1));
I3=I3.*(I3>5);
imshow(I3)

Resize png image in Delphi - incorrect alpha channel

I am resizing png images which might have alpha channel.
Everything works good, with one exception:
I get some gray pixels around the transparent areas.
The original image doesn't have any drop shadows.
Is there a way to fix this / work it around?
I am using SmoothResize by Gustavo Daud (See the first answer to this question), to resize the png image.
I cannot provide the code that I am using as I did not write it and do not have the author's permission to publish it.
I suspect that is caused by 2 things: funny RGBA values in PNG and naive resizing code.
You need to check your PNG contents. You are looking for RGB values in transparent areas. Despite transparent areas having Alpha at 0, they still have an RGB info. In your case I would expect that transparent areas are filled with black RGB value. That is what might cause the grey outline after resize if the resize is done naively. Example: What happens if code resizes 2 adjustent pixels (0,0,0,0) and (255,255,255,255) into one? Both pixels contribute by 50% The result is 128,128,128,128) which is semi-transparent grey. Same thing happens when you upscale by e.g x1.5, the added pixel inbetween original two will be grey. Usually that does not happen because image-editing software is smart enough to fill those invisible pixels with color from nearest visible pixel.
You can try to "fix" the PNG by filling transparent areas with white (or another color that is on border of your images).
Another approach is to use an advanced resizing code (write or find library), that will ignore transparent pixels RGB values (e.g. by taking RGB from closest non-transparent pixel).

Resources