Implementing the warp/liquify tool in C++ - c++

Im looking for a way to warp an image similar to how the liquify/IWarp tool works in Photoshop/Gimp.
I would like to use it to move a few points on an image to make it look wider than it was originally.
Anyone have any ideas on libraries that could be used to do this? I'm currently using OpenCV in the same project so if theres a way using that it would be easiest but I'm open to anything really
Thanks.
EDIT: Heres an example of what im looking to do http://i.imgur.com/wMOzq.png
All I've done there is pulled a few points out sideways and thats what im looking to do from inside my application

From this search 'image warp operator source c++' i get:
..... Added function 'CImg ::[get_]warp()' that can warp an image using a deformation .... Added function 'CImg ::save_cpp()' allowing to save an image directly as a C/C++ source code. ...
then CImg could do well for you.

OpenCV's remap can accomplish this. You only have to provide x and y displacement maps. I would suggest you can create the displacement map directly if you are clever, and this would be good for brush-stroke manipulation similar to Photoshop's liquify. The mesh warp and sparse point map approach is another option, but essentially computes the displacement map based on interpolation.

You may want to take a look at http://code.google.com/p/imgwarp-opencv/. This library seems to be exactly what you need: image warping based on a sparse grid.
Another option is, of course, generate displacements yourself and use cv::Remap() function of OpenCV.

Related

Disparity Map post processing in OpenFrameworks

After long hours I finally managed to get a stereo disparity map with a single camera. The result is rather spotty as one would expect, so I would like to apply some filter to improve the quality. The problem is that I'm not using pure OpenCV, but the plugin for OpenFrameworks (ofxCv), meaning I can't use this:
http://docs.opencv.org/3.1.0/d3/d14/tutorial_ximgproc_disparity_filtering.html
There has to be a way how I can apply the WLS filter, or something similar in this situation. WLS appears to be implemented in OpenCV, but I can't access it through the plugin, and direct access also doesn't seem to work.
Does anybody know how I can apply that filter, or has any other, general, disparity map post-processing advice?
I'm not sure what OpenCV functionality is available to you. But just a suggestion, maybe use the implementation from OpenCV in your project. Look at the file: https://raw.githubusercontent.com/opencv/opencv_contrib/master/modules/ximgproc/src/disparity_filters.cpp
Copy any additional files you may need to your project and try building. With basic OpenCV support you might be able to make it work.

MOG2 background subtraction Parameters

I am trying to use the OpenCVs Background Subtractor class MOG2 to seperate a person moving infront of a camera. I got everything set up and working nicely. But the resulting mask I am getting looks something like this:
(default settings)
Now what I would like to get is something like this:
(bad gimp skills :D)
I have already tryed to mess around with the parameter described in the docu, but all I managed to accomplish was something the looked like a motion blur effect...
So I was hopeing somebody with a better understanding of the algorithm or somebody who has already done something similar might be able to help me!
Thanks in advance, Foaly
I am working also with that and what I've seen is that this algorithm needs a good calibration to accomplish that goal, because you should be aware that this algorithm try to put in the background some pixels that don't show changes, e.g. in your skin major part of the pixels have the same color maybe this is the reason. I recommend to you that use other kind of methods (using zncc) if you want to use an application like the one that is showed in your question.
So I guess this were our image processing skills come into play. The first thing I would do is make the lines on the image thicker and join it it. We can use the following:
1) I would want the lines thicker. Use Morphological operators tutorial on Morphological operators with Otsu's method. This paper worked for me when I did my ear biometrics http://www4.comp.polyu.edu.hk/~csajaykr/myhome/papers/PR2011.pdf
2) Fill in connected components using opencv and clean the image
3) Segment human profile

2d graph in real-time by using opencv and c++

I have a really basic question in opencv and c++. I am trying to graph something in real time by using opencv. I am looking to find a function to draw a graph in rel-time. But still unssuccesful.
I need a function that gets two arrays as an input one for x axis and one for y. I tried with this but seems not work in real-time http://www.shervinemami.info/graphs.html
I just need to know if there is something available in opencv or not.
Thanks in advance.
OpenCV provides just low level drawing primitives, so you have to look for other libraries to plot chars, or create the code yourself.

Face detection and image preview drawing

I'm developing application that uses DirectShow combined with C++.
Its main goal is to capture users' faces.
I have reached the phase when I capture a image from my webcam.
The problem is I need an intelligent render. In fact, I need that render to be able to detect a face inside a rectangle.
I'm wondring if there is a filter that I can use for this purpose,
or if I need to create my own custmized filter.
If so enlighten my mind.
It would look like this:
I need to understand how I can draw a recangle in my render in the first place. Because otherwise, even if I know the algorithm, I will not be able to apply it. This is my main goal now.
I have some idea but I don't know if they are correct. I think I need to grab each frame separately and apply some modification in some pixels, like what's drawn in the live render.
Have a look at OpenCV
Quick look inside and I found this.
Making your own "filter" that works well is no easy job.
Are you talking about automatic detection of where there is something like a human face in the shot you have taken with the webcam? In this case object detection algorithms like Viola-Jones might be interesting for you.
If a commercial package is an option, you can use the Montivision Filter SDK which includes filters that should do the job out of the box. They offer a free eval which is perfect for experimentation.

Rotating an image in C/C++

I need code for rotating an image in C++ which functions like imrotate function of matlab.
Please suggest a good link. Or if someone can provide the code for imrotate.
Or at least please explain the algorithm.
Its not a homework. I need this code for my project. And we can use any external library or code.
OpenCV2.0 has several computer vision and image processing tools. Specifically warpAffine (by defining the rotation matrix) will solve your problem with rotating an image.
The 2x3 transformation matrix mentioned in the documentation is as follows:
where θ is the angle of rotation and tx and ty is the translation along the x and y axes respectively.
You can get the source code here.
Also, OpenCV2.0 has many MATLAB-esque functions like imread, etc.
Magick can help you. Read this PDF and search for rotate.
Check this hope it helps .
Other questions on stack overflow on the same topic experts opinion on it.
libgd has image rotation functions.
There is no built-in way of accomplishing this in C++, short of writing your own function for manipulating binary data, which yields other problems like "How do I decompress a jpg/png in C++?"
Your best bet is a 3rd party graphics library such as libSDL