How to remove the shadows from these pictures using python opencv? - python

How to remove the shadows of the seeds? Also I would like to know if there is a way to change the color of all the seeds to red colour?

It seems rather easy to detect the seeds since your background is homogeneous. You can start by some simple image processing (contrast enhancement, thresholding, contour detection) to detect the seeds and then you can plot red blobs (with the same area as the detected regions) on the original image. As for the shadows, you can check this question (How to remove the shadow in image by using openCV?).

I think you can solve with this paper and it will make you interesting.
The algorithm described there works quite well and this will be a good example for you in using opencv.
And you can find the source code here
Regards.

Related

Eliminate the background (the common points) of 3 images - OpenCV

Forgive me but I'm new in OpenCV.
I would like to delete the common background in 3 images, where there is a landscape and a man.
I tried some subtraction codes but I can't solve the problem.
I would like output each image only with the man and without landscape
Are there in OpenCV Algorithms what do this do? (then without any manual operation so no markers or other)
I tried this python code CV - Extract differences between two images
but not works because in my case i don't have an image with only background (without man).
I thinks that good solution should to Compare all the images and save those "points" that are the same at least in an image.
In this way I can extrapolate a background (which we call "Result.jpg") and finally analyze each image and cut those portions that are also present in "Result.jpg".
You say it's a good idea? Do you have other simplest ideas?
Without semantic segmentation, you can't do that.
Because all you can compute is where two images differ, and this does not give you the silhouette of the person, but an overlapping of two silhouettes. You'll never know the exact outline.

Image processing with python for braille language

how can I extract white paper(that contains Dots 'braille language') from image in image processing ?
I tried a lot of things but I want to extract it completely so I can do threshold on the result.
One way you might implement braille detection is using a Hough transform from OpenCV's library.
There is a function cv.HoughCircles() that allows you to specify a radius for circles you are looking for, assuming each sheet of braille paper will be the same distance from your camera you have a known tolerance for that.
I would just be worried about the clarity of white braille bumps on white background paper, which perhaps could be fixed using a perpendicular light source to create some shadows for each bump.

ways to reduce noise + smooth the image to create a mask for the largest object

I need your advice, guys! So I am trying to create a mask for a football (i.e. soccer) pitch, and if I only use filtering by the most common hue/saturation/value values, I get the following image
As you can see, the desired part is inside the grey boundary I drawn and there is a lot of noise here - trees, lines, external objects, and of course I would like to get rid of it. The desired outcome is something similar to this:
I thought about an algorithm that would transform the first image into another by analyzing each pixel's surrounding and color it white if more than threshold% of pixels into a (x, x) square is white, otherwise black.
Do you know if there is an implementation on openCV or similar libraries for this or I should build it from scratch?
Also, maybe you can propose other way to deal with the noise and external objects? I already tried the morphological transform and blurring techniques, but either I don't do it right or it doesn't work well for my problem.
Thank you in advance for your advice!
I actually found an easy implementation of the algo I proposed - I simply use cv2.blur on the image and then filter with cv2.inRange, so it does exactly what I wanted it to do.

Add shadow to image using opencv python for augmented reality

I have been assigned to augmented reality based on opencv python.
Project description:
Need to take an interior room image,Paint that interior with our own colour.
Proceeded:
I have taken an image and made the colouring in that with the use of edge based method,floodfill.
Issue:
Now what is the issue is to give the liveness of image.In my point liveness is the shadow.if i colouring some area its getting coloured but the the colour is fitted over the shadow
Requirement:
Now i need to add the original shadow to the image after colouring.
Here i have attached the original image and coloured image for reference[Result image]
I think you have to apply a full black image with a low alpha value.
Realized that OpenCV has not good solutions for that, but you can use Pillow.
http://www.leancrew.com/all-this/2013/11/transparency-with-pil/

Background subtraction when background brightness is unknown

I'm currently working on a computer vision project, and got most of my algorithm working. However I'm currently doing background subtraction manually on every image. This is because the most common background subtraction algorithms that I can find make use of thresholding, and my project should deal with backgrounds both brighter and darker than the object I want to extract.
This is the way I am subtracting the background currently (using python and the scikit stack):
val = filters.threshold_otsu(image)
return image > val
Of course, this only works with backgrounds darker than the subject.
I had the idea of finding whether or not the background is bright, and then depending on that change the sign of the inequality, but could not find a way to do that.
Is there a background subtraction algorithm which is able to handle both bright and dark backgrounds, or is there another way to solve this problem?
There are no fixed method of solving your problem generally. Foreground and background can be defined differently according to situations.
That being said, it is not impossible to use some heuristic method to make the algorithm work on your dataset. It will be helpful if you can share some of the images to give us a better understanding of your definition of foreground and background.
Here are some of heuristic method that might help:
Run Ostu thresholding with both THRESH_BINARY and THRESH_BINARY_INV. Then assuming your foreground is always centered, choose the result where the a large portion of the center region is white.
If the foreground is always larger than backgorund or vice versa, calculate the area of white region instead.
There are several automatic thresholding techiques available. One of them is Otsu.
http://www.labbookpages.co.uk/software/imgProc/otsuThreshold.html
It is implemented in opencv (https://docs.opencv.org/trunk/d7/d4d/tutorial_py_thresholding.html)
import cv2
img = cv2.imread('noisy2.png',0)
ret2,th2 = cv2.threshold(img,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)

Categories

Resources