The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Tag Info

Hot answers tagged image-processing

48

In convolution, two mathematical functions are combined to produce a third function. In image processing functions are usually called kernels. A kernel is nothing more than a (square) array of pixels (a small image so to speak). Usually, the values in the kernel add up to one. This is to make sure no energy is added or removed from the image after the ...

16

Here is the best article I've read on the topic: Efficient Gaussian blur with linear sampling. It addresses all your questions and is really accessible. For the layman very short explanation: Gaussian is a function with the nice property of being separable, which means that a 2D Gaussian function can be computed by combining two 1D Gaussian functions. So ...

13

(XYZ) can be the RGB colour you want to tint your scene by. For the above scene it can be a red colour (1.0, 0.0, 0.0) or something similar with a strong red component. Bear in mind that since you are applying the colour in a multiplicative way it will act as a filter suppressing original colour components. So if your scene is mostly green but you apply (i....

13

In general, a convolution is performed by taking the integral of the product of two functions in a sliding window, but if you're not from a math background, that's not a very helpful explanation, and certainly won't give you a useful intuition for it. More intuitively, a convolution allows multiple points in an input signal to affect a single point on an ...

11

The most important thing to consider when implementing the Gaussian blur is, as others have pointed out, to separate the 2D convolution filter into two 1D convolutions because it brings the complexity down from $O(n^2)$ to $O(n)$. But there are two more tricks you might want to consider in an actual implementation: The filter has a certain radius and ...

11

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 ...

9

It seems like you're asking two things. I can't really speak technically about JBU, but I can give an overview of the necessary concepts and bilateral filtering generally. You'll probably need to find more details yourself, but this should give a coherent structure to start from. Fixing "Image"s Many image-processing people view filtering as either ...

9

it is quite easy to measure the local max frequency in an image (at least as a low resolution mask, with some regularization). Several papers of the MIT graphics group have been around detecting and processing from this kind of clue, with regular or coded aperture cameras. e.g. Defocus Magnification and Image and Depth from a Conventional Camera with a Coded ...

8

TL;DR: 2*1LSB triangular-pdf dithering breaks in edgecases at 0 and 1 due to clamping. A solution is to lerp to a 1bit uniform dither in those edgecases. I am adding a second answer, seeing as this turned out a bit more complicated than I originally thought. It appears this issue has been a "TODO: needs clamping?" in my code since I switched from normalized ...

7

Like in any other kind of signal processing, the relationship is Nyquist's theorem. An image is a discrete sequence of samples of a continuous signal. If the original signal has frequency components higher than half the sampling rate, then there will be aliasing. To put that another way, if you look at the real-world size of a pixel, any details smaller than ...

6

Extending Kostas Anagnostou's answer, a commonly used formula for desaturation is float value = 0.3 * InputR + 0.59 * InputG + 0.11 * InputB; This accomodates the fact that different color hues are perceived with a different intensity by a human observer. Further following the example, you would then define some tint color that is multiplied with the ...

6

I believe that Zrep is the output range. In 8-bit it would be 255. Let's say fmin was 25, fmax was 132. You want to scale that range to 0-255. The part of the equation in brackets: [(f-fmin) / (fmax-fmin)] will give you a percentage - a value between 0 and 1. If f is 25, you'd get 0%. If f is 89, you'd get ~60%. If it's 132, you'd get 100% So once you have ...

6

JPEG is a lossy format and depends on both the 2d frequency components of the image and the user specified quality level. It is possible that down-scaling an image can increase the higher frequency components and potentially result in an increase in file size, typically higher frequency components a encoded using a higher number of bits compared to lower ...

6

There are, and I am looking forward to seeing the specifics of other answers, but one way to deal with this is to not have the noise (or as much noise) in the source data to begin with. The noise is coming from the fact that there is high variance in the rendering - the number of samples you've taken haven't converged enough to the actual right answer of ...

6

In theory, it is possible to stuff every sample distribution into a texture to "pre-bake" it for fast access. The question is whether any of the results might be useful. For blue noise, this makes a lot of sense, as blue noise distributions have global influence and are hard to evaluate at runtime. Uniform random sampling, on the other hand, is so simple ...

5

The effect in the photo is very close to a simple scale-bias per pixel. After a bit of tweaking, I found that applying the transformation: $x' = 0.77x + 38$ to the raw pixel values (as bytes) gives something quite close to your output: In this case the effect of the scale-bias is to reduce the contrast (scale factor < 1) while keeping the overall ...

5

Explanation With a non-linear scale, you apply different weights for each pixel (or whatever unit you are using). You can use Euclidean distance towards the closest pixels in both directions to determine the weights. Example Normalization For example, in the image below, the red image is the downsampled image (3x3) and the black image is the original ...

5

A quickly formulated method, read first one that popped in my brain (not best), could be. Find the closest points on a parametric spiral for each sample (read A Pixel Is Not A Little Square3). Then place the samples on a line by placing the pints in one axis by how far they are from your spiral line and the other by what the closest point is. You can then ...

5

One way I can think of is to make a "signed distance transform" of the image where there is information for each pixel about how far the pixel is to the closest surface of the shape. Since it's signed, youll be able to know if the pixel is inside or outside he shape, and by how much. Using this knowledge, you could easily make a new image, where the pixel ...

5

This is a quite common property of smoothing in 3D. When you have some data and you smooth it out you get some kind of average of the local variation. And this works fine, and stably, in one dimensional graphs. But when your entire data set is being smoothed over its coordinates the neighboring coordinates drag your data with them. Those again are dragged ...

5

The top Zuckerberg image looks like you first convert your background Zuckerberg image to grayscale. Then you can add a second layer with the rainbow texture but use the 'Screen' blending mode, this will cause it to colourise the layers beneath it, but in such a way the whites are preserved. You could also try 'Multiply' mode too if the results are too ...

5

An affine transformation doesn't have enough freedom to do what you want. Affine transforms can be constructed to map any triangle to any other triangle, but they can't map any quadrilateral to any other quadrilateral. One way to see this is that the matrix for a 2D affine transform has only 6 free coefficients. That's enough to specify what it does to 3 ...

4

It speed does not matter, I suggest to use a truncated sinc or a Lanczos isotropic kernel: to compute a target pixel, you back-rotate the filter and convolve it with the image. Since it is isotropic, it is separable and you can even use a square filter parallel to the axis of the source image.

4

It's called trilinear interpolation. You first do a bilinear interpolation of the higher-res texture, then do a bilinear interpolation on the lower-res texture, then interpolate between the 2 results. The weight of the final interpolation is based on where between the 2 textures your Z-coordinate falls. If 0 is fully the low-res texture and 1 is fully the ...

4

A very simple low memory approach If you really want to use as little memory as possible, it can be done with not much more memory than that required to store a single image (the first frame) provided it is acceptable to do some preprocessing in advance. If you copy the following jumbled image, this jsfiddle will take it as input: It will then move the ...

4

This depends on your calculations really, since you can do it either way. However, probably when you reach tone mapping you will be in linear space (i.e. no gamma correction has been done yet and you don't assume non-linear space for your calculations). Assuming this, gamma correction should be applied after tone mapping, otherwise you have "linear" tone ...

4

The issue is the difference between pixel and point sizes. On macOS and other Apple platforms, the user interface is measured in points, which don’t necessarily map one-to-one to pixels; on a Retina screen like the one you’re using, 1 point is 2 pixels. Since there’s no way for the system to know whether your image’s scale is the same as the screen’s, it’s ...

4

I don't have any direct experience doing this so I might be missing an obvious solution or tool. That said, what you describe is in programming terms comparatively easy to achieve. The basic structure of such a custom processing would be: Open the image file and get access to the array of pixels it contains. Iterate over all the pixels and inspect/transform ...

4

It's generally a good idea to add noise like this when you're using a gradient, to avoid visible banding in the gradient, especially on smartphones. Often smartphone screens claim to be 24-bit colour but the panel itself is actually only 16 or 20 bit. The chief difference between the example and your attempt to reproduce it is that your noise is in RGB ...

3

One way to represent a complex-valued function in a bitmap is to use one color channel for the real component and one for the imaginary component. For example, rendering a complex plane wave (your equation) with R = real, G = imaginary looks like this (click for shadertoy):

Only top voted, non community-wiki answers of a minimum length are eligible