What I am going to do
Remove background from an image (removed area should be transparent)
Add a white outline to the image
I investigate ways to remove background from images and found several ways using opencv or other libraries like backgroundremover (https://github.com/nadermx/backgroundremover). But I can't find a solution to set the outline.
Related
I want to extract the person in a image without any background.I want to do this for multiple images of the same kind.Please help me do so using python which can automate this process.
https://depositphotos.com/148319285/stock-video-man-run-on-green-screen.html
I,ve tried using canny edge detector could only find edges but couldnot crop it.Is there any alternative way to detect background and remove completely.
Background subtraction using opencv. Check the link for examples and details: https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_video/py_bg_subtraction/py_bg_subtraction.html
In case of such prepared images, you migth find useful simple thresholding: https://docs.opencv.org/3.4.0/d7/d4d/tutorial_py_thresholding.html in your case you would need to get grayscale image by extracting green channel from image. It would produce binary (black and white ONLY) image with white for background and black for object (or reverse depending on your choice).
I am currently trying very hard to figure out a way to make these four trapezoid images into one nice image. The final image should look something like this(used photoshop to make it):
That above image will be complied with four of these images:
The problem is that when I try to rotate and combine these images, the black surroundings come into the final image as well like this:
How am I supposed to rid of the blacked out area or make it transparent? I've tried using a mask but that only make the black area white instead. I have also tried using the alpha channel, but that didn't work(although maybe I was doing wrong). Any ideas on what I can do in OpenCV?
I did actually figure it out. I did it with these steps:
Create two SAME SIZED black backgrounds with numpy zeros
Put one image in each background where you want them(for me, it was left and top)
Then all you need to do is cv.add(first, second)
The reason it works is because black pixels are 0,0,0 so adding to a pixel that is, say, 25,62,34, the pixel doesn't change and thus rids of the black corner.
I'm trying to make a GUI in tkinter that uses one image as an overlay on top of another, but when I place the image over the lower one, the transparent area of the image appears as grey.
I've searched for solutions to this, but all the results that I've found have pointed towards using PIL.
Is it possible for me to use transparent, or partially transparent images in the python tkinter module without using PIL?
You could use some basic photoshop tools like the magic wand tool to remove the background, but keep in mind, some PNG format images have a faint background. This is either in the from of a watermark, or the image background was rendered with a lower opacity than the rest of the image. Your GUI may also have a layer placed above the images by default. Does it appear on each image seperatly when loaded into the GUI?
I have a problem with python image processing.
I have an image that is just a pattern.
I have another image that will have a solid black line somewhere on it.
I would like to replace the solid black line with the pattern.
I have looked at PIL and I have not been able to figure out how to do this, since it seems like the only way I can get the pattern out of the first image is to copy the image, and I can't figure out how to paste over only the black pixels.
Someone also recommended pythonmagick to me, but it doesn't have docs.
Using PIL, convert the white/black line into a mask which only allows to see through the black pixels, and use it to mask an image constructed by tiling the pattern image sufficient times in x/y to be large enough to cover the extent of the black line. See How do I generate circular thumbnails with PIL? for some highly useful answers.
I entered a captcha-ed website I would like to get rid of. Here is some sample images
Since the background is static and the word is so computer-generated non distorted character, I believe it is very do-able. Since passing the image directly to Tesseract (OCR engine) doesn't come a positive result. I would like to remove the captcha background before OCR.
I tried multiple background removal methods using Python-PIL
Remove all non-black pixels, which remove the lines but it wouldn't remove the small solid black box.
Apply filter mentioned another StackOverflow post, which would not remove the small solid black box. Also it is less effective than method 1.
Method 1 and 2 would give me a image like this
It seems close but Tesseract couldn't recognize the character, even after the top and bottom dot row is removed.
Create a background mask, and apply the background mask to the image.
Here is the mask image
And this is the image with the mask applied and grey lines removed
However blindly applying this mask would generate some "white holes" in the captcha character. And still Tesseract failed to find out the words.
Are there any better methods removing the static background?
Lastly how could I split the filtered image into 6 image with single character? Thanks very much.
I can give you a few ideas to have a try.
After you have applied step 3, you may thicken the black edges in the images using PIL so as the fill the white holes. And I guess you are using python-tesseract. If so, please refer to Example 4 in https://code.google.com/p/python-tesseract/wiki/CodeSnippets
In order to extract the characters, you may refer to Numpy PIL Python : crop image on whitespace or crop text with histogram Thresholds. There are methods about analysing the histogram of the image so as to locate the position of the whitespaces from which you can infer the boundary.