I understand how an artist would make seamless textures by hand, but how can a computer program automate that process? Software like PixPlant is capable of doing this, but I don't understand how it does this.
Seamless Textures
texture;algorithm;image processing
For these types of algorithms, you usually have to rely on multiple forms of texture synthesis. That doesn't mean you have to generate the whole texture from scratch. For example, you could regenerate the sides of the texture to achieve a seamless effect. This answer may not be complete because it's a large field, and different approaches will have various effectiveness depending on the input image.Naive blur along edgesAs an artist, one way to make seamless textures is to offset the image in two directions. Then, you can blur the edges.This example isn't the best, but you can get decent results with results with certain texture types.Alternatively, you could do a minimum cut on the edge here by overlapping the image with itself, and then taking the difference between the two images.Min-cut algorithmsOne of the most popular algorithms is image quilting. The idea behind this is separate the texture into a bunch of patches. You fill in the texture by first randomly picking a subset of patches from your total set of patches and picking the one with the least amount of error when you overlap the patch with it's neighboring patch(es). You then perform minimum cuts along the overlapping regions.My experience with this algorithm is that it works well for many textures that have round details. If the texture is grass for instance, then it can perform poorly. The amount you overlap each patch also has a large impact on quality. The larger the overlap, the better the match, but the more likely there will be repetition. Also, if the subset of candidate patches is too large, then you'll get repetition. Otherwise, you might not find good matches.There are extensions of this algorithm including PatchMatch (which was used in Photoshop).Gradient correctionAnother way to handle seamless textures is to remove the gradient. Poisson image editing can help with this if you break up your image and use the various pieces are foreground and background objects.A simpler approach is to create a low-frequency (e.g., mipmap) of your texture and then remove the gradient of your image. Of course, high frequency data won't be seamless, but you can remove that with other algorithms.Computer vision approachesYou could use various computer vision approaches as well. The idea here would be that you keep important features intact as you attempt to tile your textures. For instance, if there's a texture of dirt with a rock on the edge of the picture, using various feature detectors such as difference of Gaussians could help you identify this rock and remove it before you do the tiling. You might need to fill in the rest of the texture where the rock was removed, but this could help with making the image more seamless.Additional ReferencesImage quilting and PatchMatch high-level explanationGradient domain compositing