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

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.

Related

Remove differences between two video frames

Im trying to remove the differences between two frames and keep the non-chaning graphics. Would probably repeat the same process with more frames to get more accurate results. My idea is to simplify the frames removing things that won't need to simplify the rest of the process that will do after.
The different frames are coming from the same video so no need to deal with different sizes, orientation, etc. If the same graphic its in another frame but with a different orientation or scale, I would like to also remove it. For example:
Image 1
Image 2
Result (more or less, I suppose that will be uglier but containing a similar information)
One of the problems of this idea is that the source video, even if they are computer generated graphics, is compressed so its not that easy to identify if a change on the tonality of a pixel its actually a change or not.
Im ideally not looking at a pixel level and given the differences in saturation applied by the compression probably is not possible. Im looking for unchaged "objects" in the image. I want to extract the information layer shown on top of whats happening behind it.
During the last couple of days I have tried to achieve it in a Python script by using OpenCV with all kinds of combinations of absdiffs, subtracts, thresholds, equalizeHists, canny but so far haven't found the right implementation and would appreciate any guidance. How would you achieve it?
Im ideally not looking at a pixel level and given the differences in saturation applied by the compression probably is not possible. Im looking for unchaged "objects" in the image. I want to extract the information layer shown on top of whats happening behind it.
This will be extremely hard. You would need to employ proper CV and if you're not an expert in that field, you'll have really hard time.
How about this, forgetting about tooling and libs, you have two images, ie. two equally sized sequences of RGB pixels. Image A and Image B, and the output image R. Allocate output image R of the same size as A or B.
Run a single loop for every pixel, read pixel a and from A and pixel b from B. You get a 3-element (RGB) vector. Find distance between the two vectors, eg. magnitude of a vector (b-a), if this is less than some tolerance, write either a or b to the same offset into result image R. If not, write some default (background) color to R.
You can most likely do this with some HW accelerated way using OpenCV or some other library, but that's up to you to find a tool that does what you want.

How is it possible to differentiate between these images

Attached below three images that I have processed already. The last part is to differentiate between the good samples and bad one
this two pictures are good samples
while the third one is not.
any idea how can I do image processing to solve this task.
i'm using OpenCV with python
Try counting the number of endpoints. Look at:
How to find endpoints of lines in OpenCV?
How can I find endpoints of binary skeleton image in OpenCV?
Detect holes, ends and beginnings of a line using openCV?
Explanation:
As you can see, once you have binarized and skeletonized (by the way, you should have 1px width lines so check the way you obtain the skeleton) the image you can see that the number of endpoints in the wrong one is 4 rather than in the other which should be 2.
Anyway you should attach the original pictures also, because maybe there is a better way to tackle the problem.

Detecting changes between two pictures

I am a beginner in python & image processing.I have the following image.
I would like to detect the changes between this picture and another one where the other one may be
taken from a slightly different angle or the object is translated
have different light conditions
and the changes may be
a change in color in part of the object
an extra or missing part
After various searches I thought about using ORB to detect the matching parts and remove them from the picture then use contour to extract and compare the difference.
But I cannot seem to find a way to remove the matching parts from the two images.
I am open for all suggestions / better way to approach the problem.
edit:
Sorry , forgot to mention that the color change could either be white or pink
Looking at your image, it appears there are three dominant colors. If this is always the case the first thing that comes to mind is to apply a color K mean algorithm with three clusters, like explained here.
The center color of each cluster would then give you information on the color of the tubes, and the size of each cluster (# of pixels belonging to that cluster) would give you if there are extra or missing parts.

Join the two images

I am quite new to OpenCV and DIP in general so I need bit of help in stitching of two images. The problem background is, there are two pieces which have their adhesives/glue torn apart from two joined pieces of plastic. This is the image of "glue" on the base:
and this is the image of "glue" on the other attached face:
As the background of the the images is not the same, I read that it's not possible to do stitching (because different features). And these two pieces are like jigsaw pieces which needs to rotated, so the problem is not straightforward like panaroma stitching.
How do I join such images together?
I was thinking of finding the white color countours and then keeping one image fixed, rotating the other one and finding area of merged countours, also storing the angle of what I rotate. The area would become smallest when there would be perfect match.
This is not a complete answer, (no-one said answers have to be complete), but it may inspire you or someone else to work out a method.
I flipped vertically and flopped horizontally one of your images and then put them both into Photoshop on two separate layers. I then set the "Blending Mode" to Difference which is always a great way to align images - because they normally go black when images are aligned and there is no difference.
I then moved one layer around on the other. I guess you will need to do something similar to solve your problem - you just need to find something that your code can maximise or minimise.

Detecting Similar images [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Image comparison algorithm
So basically i need to write a program that checks whether 2 images are the same or not. Consider the following 2 images:
http://i221.photobucket.com/albums/dd298/ramdeen32/starry_night.jpg
http://i221.photobucket.com/albums/dd298/ramdeen32/starry_night2.jpg
Well they are both the same images but how do i check to see if these images are the same. I am only limited to the media functions. All i can think of right now is the width height scaling and compare the RGB for each pixel but wouldnt the color be different?
Im completely lost on this one, any help is appreciated.
*Note this has to be in python and use the (media library)
Wow - that is a massive question, and one that has a vast number of possible solutions. I'm afraid I'm not a python expert, but I thought your question was interesting - so I wanted to propose a method that I would implement if I were posed with this problem.
Obviously, the two images you posted are actually very different - so you will need to consider 'how much different is the same', especially when working with images and considering different image formats and compression etc.
Anyway, for a solution that allows for a given difference in colour values (but not for pixels to be in the wrong places), I would do something like the following;
Pick two images.
Rescale the largest image to the exact same height and width as the first (even distorting the image if necessary).
Possibly grayscale the images to make the next steps simpler, without losing much in the way of effectiveness. Actually, possibly running edge detection here could work too.
Go through each pixel in both images and store the difference in either each of the RGB channels, or just the difference in grayscale intensity. You would end up with an array the size of the image noting the difference between the pixel intensities on the two images.
Now, I don't know the exact values, but you would probably then find that if you iterate over the array you could see whether the difference between each pixel in the two images is the same (or nearly the same) across all of the pixels. Perhaps iterate over the array once to find the average difference between the pixel intensities in the two images, then iterate over the image again to see if 90% of the differences fall within a certain threshold (5% difference?).
Just an idea. Of course, there might be some nice functions that I'm not aware of to make this easy, but I wouldn't hold my breath!
ImageMagick has Python bindings and a comparison function. It should do most of the work for you, but I've never used it in Python.
I think step 2 of John Wordsworths answer may be one of the hardest - here you are dealing with a stretched copy of the image but do you also allow rotated, cropped or in other ways distorted images? If so you are going to need a feature matching algorithm, such as used in Hugin or other panorama creation software. This will find matching features, distort to fit and then you can do the other stages of comparing. Ideally you want to recognise Van Gogh's painting from photos, even photos on mugs! It's easy for a human to do this, for a computer it needs rather more complex maths.

Categories

Resources