I need to keep only red text from images like this one.
Image with text
I have tried turning all pixels with less than 210-240 value for red in RGB to black, but it depends much on the image and the light of it, so it is not a good solution and is not always working.
I would need to make it using Python.
Related
I'd like to remove this sort of tv-like noise from a .jpg image in order to get a .png image with transparent background.
This is because I'll later need to overlay this picture over another one.
I've tried 1,
2,3, but all of them probably work only on black backgrounds.
I'm coding with Python and I thought OpenCV would help.
Do you have any idea? Thanks! :)
Given that the noise is nearly exclusively black and white (i.e. desaturated) whereas the fish is colour, I would convert to HSV colourspace and look to the Saturation channel for providing separation - the middle one in the row below:
I'm doing a real time image processing at about 20 FPS.
I'm trying to filter 3 colors (using opencv, python). Those are: red, blue and yellow from a frame in which the light is not always constant (meaning sometimes the ambiental light can make my red pixel (B=119, G=84, R=199), and sometimes (R=60, G=0, B=0) - this is when the light comes right in front of the camera).
I know about a formula like so : if 2R-B-G is grater or equal to 0, then the pixel will go high (it remains unchanged). If the pixel goes negative, i should make it black. The problem is that this involves a pixel by pixel processing and i'm not sure it is what i'm searching for. I would like to try this approach but i don't know how could i do it a little bit faster (masking and cv2.bitwise_and() after each pixel checked is the only ideea that I have, and it will take ages)
For the moment, i am just creating a binary_mask
cv2.inRange(bgr_sliced_img, (low_blue, low_green, low_red), (upper_blue, upper_green, upper_red))
The problem with this is that it is impossible to adjust the parameters so that i get the red /blue/ yellow values visible in darker images as well as in bright images without seeing other wrong objects.
I've read this and i don't really know how could i use the median intensity in my frame. I think this is close to what i want, but i have no ideea how could i implement this.
I will provide 3 pictures that ilustrates the problem . The traffic stop sign is red, but because of ambiental light, its red is changed.
I would like to find some algorithm that will "see" the red color in each 3 pictures without the need of manual modifying parameters.
*I should mention that i'm searching for the traffic sign in a region of interest of about 100x100 pixels, not in the entire image
I'm very new to Python and am exploring it's use to allow users to build custom images. The idea is that the client would select a few options and the image would be created on the server then downloaded (or used for other things on the server side).
The image is composed of many images, most of which are small icon type of images that are irregular shapes and have transparency. All layers are .png files.
I've tried using Pillow but it seems the image needs to be the same size as the overall image to properly use the transparency of the top layers.
Here's what I've tried so far:
from PIL import Image
background = Image.open("Background.png")
foreground = Image.open("Trim.png")
fire = Image.open("Type_Fire_Large.png")
background = Image.alpha_composite(background, foreground)
background.paste(fire, (150, 150))
background.show()
The image looks like this:
Background.png is the shaded "noise" and Trim.png is the grey diagonal lines. The best part: Trim.png has the center transparent and is able to show Background.png in the middle. But it's also the same size as the image.
The problem is Fire; notice how theres that black border (and odd fuchsia dot). The documentation states that the overlay image needs to be the same size. But it seems like a common scenario where someone would want to place a smaller icon with transparency on top of another image and compose them into one image.
I'm not attached to any particular library, I'm wide open to ideas and alternatives. The only thing I'm trying to do is keep it simple, so creating an entire game engine or the like to produce an image would probably be too much.
To just paste one png on top of another, respecting transparency, try
background.paste(fire, (x,y), fire.convert("RGBA"))
First I'd say Johannes Holmberg already answered your main concern: The missing transparency.
But I can hopefully explain what it's about with that odd fuchsia dot:
A transparent color image is usually stored as RGBA (RGB for Red, Green, Blue and A for Alpha). Here Alpha defines the transparency, from no transparency to full transparency.
Overlaying the images the correct way we see the GIMP Logo but the color stripe is almost invisible - because it's (almost) transparent.
But - as every pixel could be possibly visible - every pixel does still have a color. Even those pixels with 100% transparency. Thus, if we do not take Alpha into consideration we see each pixel color without transparency. This way we might have disturbing colors that are usually not disturbing at all - as long as they are fully transparent.
I have an image that was taken and had a bayer filter applied to it. I am trying to correct the color because depenging on what filter we apply (BG 2 RGB for example) it comes out with a tint, be it yellow, blue, green, pink etc... I am using the python image library to try and fix the image.
I have taken an image of the visible spectrum and can make it so that one or two colors are right by multiplying by the correct pixel weight but then the other colors go off. For example I can make white look great but then blue turns pink.
Is there any way besides modifying the bayer filter that I can process this image, hopefully in python with the PIL to fix this color imbalance.
Thanks!
I want to capture the motion of a red paper on a white background in Linux using Python? I will be using OpenCV and an image library to create images at 30fps. Is there a way I can detetmine the position of the red paper (or a point on it) without going through every pixel in the image, since that would make it horribly slow. Or is there a better way of doing this altogether?
The code for reading the webcam is posted here.
Here is the full code, but for yellow paper. Change color range in line 18 for red color.
And it works only if single yellow paper is present.
And here is another code for the same, but now it works even if more than one yellow paper is present. Again change it to red yourself.