How to do merge image layers like imagick does in libvips - vips

I am using libvips php library i want to merge image layers using libvips. Does any method in libvips for merge the image layers like imagick has as below
$img = $img->mergeImageLayers(Imagick::LAYERMETHOD_FLATTEN);

You can use ->flatten() to squash the alpha out of an image. Docs here:
https://libvips.github.io/php-vips/docs/classes/Jcupitt.Vips.ImageAutodoc.html#method_flatten
Unfortunately, phpdoc doesn't let you document optional arguments, so you need to refer to the C docs to see the extra controls:
https://libvips.github.io/libvips/API/current/libvips-conversion.html#vips-flatten
You can remove bands with unset, so you can drop alpha from an RGBA image with eg. unset($image[3]).

Related

add multiple images to a video using aws mediaconvert

I'm trying to add images to a video using mediaconvert. I used mediaconvert graphic overlay/ image inserter to perform this task. However, the image is overriding the given video in the output for the given duration. I want the image to be still at first and then start the video from the beginning if I add an image and similarly for the rest of the images. Can this be done by using aws-mediaconvert?
Overlays are normally used for things like watermarks and logos or simple sports scores/news tickers etc. Images you want to appear over the top of the video.
You could create a clip of blank video to insert into your output, then apply the overlay to just that?
Another option is to convert the image to a video yourself with ffmpeg and insert that into your output?

Replace white background of image with transparent using C++ / OpenCV or Matlab

Using C++ / OpenCV or Matlab I'm trying to find a method to replace the white background of an image from file with a transparent background and then save the image for further use elsewhere. (The image is similar to something like this: http://www.psdgraphics.com/file/monitor-on-white-background.jpg)
I understand this task can be completed easily with simple image editing software but I need to do this for a large batch of images. I've tried methods such as Make white background transparent png matlab as well as a bunch of others with no luck.
Thanks!
Load the image. Loading images in OpenCV
Convert it to a 4 channel image. OpenCV: transforming 3 channel image into 4 channel
Determine where the background is adjust the alpha channel of those pixels accordingly. I don't know what your images look like, but if there is no other white in your images, it's a fairly simple task. (If a pixel is white, then it should be transparent.) Otherwise, if there is other white in your images, then you need to look for the contiguous region(s) of white that make up the background. See Flood Fill Algorithm
Save the image (See the link from 1.)

How to make motion history image for presentation into one single image?

I am working on a project with gesture recognition. Now I want to prepare a presentation in which I can only show images. I have a series of images defining a gesture, and I want to show them in a single image just like motion history images are shown in literature.
My question is simple, which functions in opencv can I use to make a motion history image using lets say 10 or more images defining the motion of hand.
As an example I have the following image, and I want to show hand's location (opacity directly dependent on time reference).
I tried using GIMP to merge layers with different opacity to do the same thing, however the output is not good.
You could use cv::updateMotionHistory
Actually OpenCV also demonstrates the usage in samples/c/motempl.c

Augmented Reality: Render Video on top of a marker

I'd like to render a video (can be any format as long as it works) on top of a marker, but I am not sure how to do this. I am using Artoolkit for desktop-based AR and QCAR for mobile AR. Eventually I want to get it done for both systems, therefore I am preferably looking for a video-library that I could use on both platforms.
Basically I know the steps that have to be done:
- load video file
- extract image according to current time
- use image as texture
- apply marker's transformation matrix to textured rectangle
Which libraries could I use to achieve the first two steps?
Which libraries could I use to achieve the first two steps?
Take a look into the libavcodec library (you can start here), but take into account that it is quite complex.

How to convert photos to Polaroid-like programmatically?

How to convert modern day photos to the look and feel of those Polaroid photos ? References and/or sample codes are welcome. Thanks!
Convert the images to HSV (cv::cvtColor) then look at adjusting the hue/saturation values
see http://en.wikipedia.org/wiki/HSL_and_HSV for a rather too technical article
Here is a video showing how to do it in GIMP: http://www.youtube.com/watch?v=1LAUm-SrWJA and here is the tutorial: http://howto.nicubunu.ro/gimp_polaroid_photo/
You can look at various steps (each one of them would be some basic image processing operation) and glue together to make your own code. I think each GIMP operation is in turn available as a script-fu script/code.
I would suggest using blend modes along with the HSV conversion.
This website below has been of tremendous help to me while processing images to give them an 'old' look.
http://www.simplefilter.de/en/basics/mixmods.html
Do note that you need to mix and match different blend modes with color tints and blur algorithms to achieve the various Polaroid effects.
A good starting point would be look at ImagemMagick. It already does have cmdline options to change the hue and saturation of a photo. Find a parameter set that gives you the result that you want and look at the source code to see what it is doing behind the scenes..
Programmatically, you'd want to use an image processing library such as OpenCV.
A large part of the effect (besides adding the white frame) is a change in the image color balance and histogram. This is due to the degradation of the chemical elements in the Polaroid film.
The types of operations you would need to apply to the image:
Changing color spaces such as HSV;
Desaturation;
Blending with color filters (this is the suggested way here);
Changing the brightness and contrast of the image channels for the chosen color space.
Obviously, most tutorials about how to do this in Photoshop (or other photo editing apps), can be converted into programs using OpenCV.