Fit random images into one composition image using a script - python

I am trying to write a script (in bash using imagemagick or in python), to generate an image similar as in this example:
The source is 25 separate jpeg's. So far I have written a script (imagemagick) which takes each of the images and detects the contours of the person and replaces the white background with a transparent one.
The next step is to fit the contours randomly into one large image. Each image should fit into the larger image, without overlapping it's neighbors. It seems I need to some type of collision detection.
I am looking for pointers on how to tackle this problem.

Related

Computer Vision: Removing noise from an image

I need to delete the noise from this image. My problem is that I need a neat contour without all the lines like in this image.
Do you have any suggestions how to do that using python?
Looking at your example images, I suppose you are looking for an image processing algorithm that finds the edges of your image (in your case, the border lines of the ground plan).
Have a look the Canny edge detection algorithm which might be a well-suited for this task. A tutorial with an example implementation in python can be found here.

thinning algorithm and post processing for binary images

I have pictures of networks, and my goal is to process the images in order to extract the skeleton of the network.
My approach lies in two steps :
1) Going from grayscale image to binary image (Using local thresholding or Otsu method, and then a medianfilter (python function medfilt)
2) Using thinning algorithms in order to extract the skeleton of the network.
Considering the quality of the first image, I'm pretty sure I can do a lot better than that. I thus have two question :
1) Taking the last image, how would you remove all the small lines perpendendicular to the ridges, and the small gaps, that are artefacts ?
2) What algorithm would you actually advise me to use for these two steps ?

OpenCV how to replace cut out object with background

I have two images, one image which contains a box and one without. There is a small vertical disparity between the two pictures since the camera was not at the same spot and was translated a bit. I want to cut out the box and replace the hole with the information from the other picture.
I want to achieve something like this (a slide from a computer vision course)
I thought about using the cv2.createBackgroundSubtractorMOG2() method, but it does not seem to work with only 2 pictures.
Simply subtracting the picture from another does not work either because of the disparity.
The course suggests using RANSAC to compute the most likely relationship between two pictures and subtract the area thaht changed a lot. But how do I actually fill in the holes?
Many thanks in advance!!
If you plant ot use only a pair of images (or only a few images), image stitching methods are better than background subtraction.
The steps are:
Calculate homography between the two images.
Warp the second image to overlap the second.
Replace the region with the human with pixels from the warped image.
This link shows a basic example of image stitching. You will need extra work if both images have humans in different places, but otherwise it should not be hard to tweak this code.
You can try this library for background subtraction issues. https://github.com/andrewssobral/bgslibrary
there is python wrappers of this tool.

Remove background and noise from image

Im trying to remove the background from a video and get a binary images( or 8-bit) where value of the object that moves is 1 and static background is 0.
something like this:
at first I tried it with getting the difference absDiff() from running average accumulateWeighted() and the current frame but the result was not what I expected( only the edges was 1 and inside of the moving object was 0).
so I went for createBackgroundSubtractorMOG2 and createBackgroundSubtractorMOG but this is not good either( same problem ).
is there a way to get the whole moving object?
The Mixture of Gaussians method is not going to solve all your problems. Common problem is sensitivity to light conditions, e.g. attaching shadow to extracted foreground object . If the image scenario (background) is roughly the same you can refine your results with some image processing.
If the background is similar as in attached image, try to build color histogram in HSI space, create image of extracted foreground object (not mask, actual colored image) and remove pixels that color is similar to the floor (technique known from skin detection methods). In that way you could remove some shadows attached to the person/objects.
Also, if real-time processing is not crucial in your application, you could use more sophisticated background/foreground detection like SubSENSE.

Detect blob in very noisy image

I am working with a stack of noisy images, trying to isolate a blob in an image section. Below you can see the starting image, loaded and plotted with python, and the same image after some editing with Gimp.
What I want to do is to isolate and recognise the blob inside the light blue circle, editing the image and then using something like ndimage.label. Do you have any suggestion on how to edit the image? Thanks.
The background looks quite even so you should be able to isolate the main object using thresholding, allowing you to use array masking to identify regions within the main object. I would have a go with some tools from scikit image to see where that gets you http://scikit-image.org/docs/dev/auto_examples/
I would try gaussian/median filtering followed by thresholding/filling gaps. Or you could try random walker segmentation, or pherhaps texture classification might be more useful. When you have a list of smaller objects within the main object you can then filter these with respect to shape, size, roundness etc
http://scikit-image.org/docs/dev/auto_examples/plot_label.html#example-plot-label-py

Categories