nawermates.blogg.se

Warpsharp filter
Warpsharp filter










warpsharp filter

Unfortunately, while there are edge-directed interpolation algorithms, they usually don't produce continuous output. In practice this means you can get "bumpiness" in edges the warped image, since the warp interpolator doesn't do edge-directed interpolation. You can often see this in near-horizontal or near-vertical lines, where the interpolator creates gray pixels when the line straddles a scan line boundary. If the warp is done using straight interpolation, the algorithm will never output a pixel that is not in the infinitely interpolated version of the original image. This means that the amount of narrowing of edges varies with local contrast, which produces uneven edges.Ī second problem has to do with the warp. The first problem with warp sharp is that the length of the displacement map vectors is dependent upon the height of the bump map, which is in turn dependent upon the contrast of the original image. I usually use a cardinal bicubic interpolator for the warp. In other words, given a gradient (du, dv), you retrieve (u+du*k, v+dv*k) from the source, where k is usually set such that the displacement is under a single pixel. Use the gradient map as a displacement map for warping the original image - that is, you use a scaled version of the gradient vector at each pixel to perturb the sampling location in the original image.Compute a second gradient map from the bump map.Optionally, apply a blur to the bump map.

warpsharp filter

Convert the gradient map to a bump map by taking the length of each gradient vector.(Both filters can be computed together in 10 adds how this is done is left as an exercise to the reader.) Sobel filters are also popular: -1 0 +1 -1 -2 -1 In a 3x3 window, subtracting (right-left) and (bottom-top) is one way to do this. The usual way to do this is through a pair of edge detection filters that compute horizontal and vertical gradient. For each pixel in the original image, the gradient map encodes a vector that indicates the direction and rate of fastest ascent in luminance. Compute a gradient map from the grayscale image.Convert the original channel to grayscale.

Warpsharp filter code#

I don't remember how the original code worked, but here's one way to implement such an algorithm: Warp sharp is the name of an algorithm that I originally found coded as a filter for an image editing application called "The GIMP." It's based on the idea that if you can identify the edges in an image, you can warp the image to shrink the edges and thus make them appear sharper. Only works when enlarging a video, and requires a lot of CPU power. The algorithm's output has proven interesting enough that I made a VirtualDub video filter out of it: It's a hybrid warpsharp+resize algorithm that attempts to make edges as crisp as possible. In an earlier blog entry on video shaders I introduced an algorithm called warpedge as an example.












Warpsharp filter