Introduction
Dynamic Planning is so useful, but it is quite boring to just stare at the well-known Lis, LCs, backpacks, matrix concatenation and so on. Mining some visual applications makes things interesting. It plays an important role in changing image resolution and image fusion.
Seam carving for changing image resolution
Seam carving is a method that intelligently changes the image resolution (it retains the importance and removes the secondary, depending on the energy function ). You can also emphasize the content amplification and delete specific objects. Let me use several images to illustrate these meanings.
- Change the image resolution (content aware image retarget)
- Delete a specific object (Object remove)
How does seam carving achieve this? As the name suggests, it needs to find an optimal gap in the image. The pixels above this gap are the least important, in other words, this gap experiences the accumulation and minimum of pixel energy. This gap can be vertical from top to bottom, and the width is a pixel. The height can also be a pixel from left to right. Let's take a look at this magic line.
This online pixel is the least important, and deleting it is the most reasonable. If you delete a vertical slit, the image will be reduced by a pixel, and you will find the scaled image and delete it again. This will continue until you are satisfied. The figure below shows the optimal gap found during processing.
You can't help wondering how to find the least important pixels. It is to use dynamic planning. The importance of pixels is measured by the energy function. This energy function can be an image gradient (sensitive to the edge) or a Harris corner measurement, or a gradient histogram (hog ). Gradients are very simple and effective as energy functions.
Re-describe this problem for the vertical optimal line. Calculates the minimum pixel cost of all the lines from top to bottom of an image. It is worth noting that there are constraints on the pixels on the gap. Each time starting from row 3, you can only walk in the lower left, lower right, and lower right directions.
By using the dynamic planning trilogy, sub-problems are abstracted. The state transition equation is analyzed by sub-problems, and then implemented from the bottom up. M [I] [J] indicates the minimum cost of going through the J pixel of line I. So because of the constraints of the gap, it can only be m [I-1] [J-1], M [I-1] [J], M [I-1] [J + 1]. Obviously, M [I] [J] should come from the smallest of them, so that the sum will be minimized. The final state transition equation is as follows.
To achieve the basic functions of seam carving is also relatively simple, the source code in https://github.com/tpys/seam-carving
Image Fusion
This means that two overlapping images are merged into a new image without human traces. Image Fusion has two meanings: 1. Where is the overlapping area. 2. What method is used for integration. Similar to seam carving, dynamic planning is used to determine the fusion location and the optimal gap. Instead of using gradients as the energy function, the two images of overlapping areas are used as the mean variance.
Reference
Http://www.win.tue.nl /~ Wstahw/edu/2iv05/seamcarving.pdf
Http://www.statfe.com/projects/csc5280_project4/index.html
Http://www.cs.stonybrook.edu /~ Svittayakorn/seamcarving.html
Http://eric-yuan.me/seam-carving/
Http://www.cis.upenn.edu /~ Cis110/12su/HW/hw07/dynprog.shtml