WL
dimecres, 16 de març del 2016
dijous, 29 de gener del 2015
Extending your images with Inpainting
Can computers learn to paint? To some extent—definitely yes! For that, akin to human imitation artists, an algorithm should first be fed the original artists’ creations, and then it will be able to generate a machine take on them. How well? Please judge for yourself:
How does it work?
In the Wolfram Language, Inpaint is a built-in function. The region to be inpainted (or retouched) can be given as an image, a graphics object, or a matrix.
There are five different algorithms available in Inpaint that one can select using the Method option: “Diffusion,” “TotalVariation,” “FastMarching,” “NavierStokes,” and “TextureSynthesis” (default setting). “TextureSynthesis,” in contrast to other algorithms, does not operate separately on each color channel and it does not introduce any new pixel values. In other words, each inpainted pixel value is taken from the parts of the input image that correspond to zero elements in the region argument.
The “TextureSynthesis” method is based on the algorithm described in “Image Texture Tools,” a PhD thesis by P. Harrison. This algorithm is an enhanced best-fit approach introduced in 1981 by D. Garber in “Computational Models for Texture Analysis and Texture Synthesis.” Parameters for the “TextureSynthesis” algorithm can be specified via two suboptions: “NeighborCount” (default: 30) and “MaxSamples” (default: 300). The first parameter defines the number of nearby pixels used for texture comparison, and the second parameter specifies the maximum number of samples used to find the best-fit texture.
Let's see how it works. First, you import the painting and remove the border.
Next, you need to extend the image by padding it with white pixels to generate the inpainting region.
Now you can extrapolate the painting using the “TextureSynthesis” method.
Not too bad. Different effects can be obtained by changing the values of the “NeighborCount” and “MaxSamples” suboptions.
Finally, let's make a simple web application to expand an image. CloudDeploy puts the following image expansion FormFunction to the Wolfram Cloud. And EmbedCode provides the HTML code to place this web application into your website:
Subscriure's a:
Missatges (Atom)