Know a pixel is transparent - ios

I know how to get each pixel from a image and its RGBA value. My question is how to determine a pixel is transparent or not. Please help

Check if alpha part of rgba value is equal to 0, if it is that means the pixel is fully transparent. ANd if it's equal to 255 isn't transparent at all.

Related

OpenCV Pixel with "no value"

Is it possible in OpenCV to have pixels with no colour? Like a transparent layer or in gimp if you delete all colours or elements on a layer.
Yes you can using BGRA system by making the alpha value equal to 0.
Example:
cv::Mat img(ROW, COLS, CV_8UC4, cv::Scalar(B_VALUE,G_VALUE,R_VALUE,0 /* This is the alpha*/));
Now all the this cv::Mat pixels are 100% transparent. You can change the alpha value to 255 so it is fully opaque or any value in the range [0,255] for a degree of transparent.

OpenCV - Saturated pixels

Just like the title of this topic, how can I determine in OpenCV if a particular pixel of an image (either grayscale or color) is saturated (for instance, excessively bright)?
Thank you in advance.
By definition, saturated pixels are those associated with an intensity (i.e. either the grayscale value or one of the color component) equal to 255. If you prefer, you can also use a threshold smaller than 255, such as 240 or any other value.
Unfortunately, using only the image, you cannot easily distinguish pixels which are much too bright from pixels which are just a little too bright.

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).

Argb value from rgb value

I have rgb value 0, 69, 255. What would be it's argb value in silverlight. Is there any online converter that we can use.
Thanks in anticipation!
ARGB or RGBA works just like RGB except you need an extra value for alpha or transparency. Now, 0 alpha means fully transparent, while 255 alpha is totally opaque. So you probably want use the same RBG values with 255 for the alpha. You may also want to check out the documentation for Color.FromARGB.

UIImage/CGImage changing my pixel color

I have an image that is totally white in its RGB components, with varying alpha -- so, for example, 0xFFFFFF09 in RGBA format. But when I load this image with either UIImage or CGImage APIs, and then draw it in a CGBitmapContext, it comes out grayscale, with the RGB components set to the value of the alpha -- so in my example above, the pixel would come out 0x09090909 instead of 0xFFFFFF09. So an image that is supposed to be white, with varying transparency, comes out essentially black with transparency instead. There's nothing wrong with the PNG file I'm loading -- various graphics programs all display it correctly.
I wondered whether this might have something to do with my use of kCGImageAlphaPremultipliedFirst, but I can't experiment with it because CGBitmapContextCreate fails with other values.
The ultimate purpose here is to get pixel data that I can upload to a texture with glTexImage2D. I could use libPNG to bypass iOS APIs entirely, but any other suggestions? Many thanks.
White on a black background with an alpha of x IS a grey value corresponding to x in all the components. Thats how multiplicative blending works.

Resources