Search the Community
Showing results for tags 'equations filter'.
I recently wrote formulas for the Equations filter that map the initial rectangle of a pixel layer into a truncated diamond inscribed in this rectangle x=x y= h/2+(y-h/2)/(1-(1-a)*abs(1-2*x/w)) where ‘a’ is a glider-controlled variable between 0 and 1 (perfect diamond for a=0 and no distortion for a=1) To save time in experimentations, I made a macro of it, at http://www.oitregor.com/numeric/affinity_photo/divers/losange.afmacro (to be imported within Macro panel). It generally works as expected, as shown below: However it sometimes fails. I specially met up against this issue after using the Move tool. In the following picture, I prepared a detailed, simple process to show what can happen —and a possible way to avoid it. I would be happy to understand what occurs, whether it is a bug somewhere in Affinity Photo or a misunderstanding of mine.
Summary This tutorial: Is aimed users with little or no knowledge of the Equations filter. Explores what “noise” is, in the Affinity Photo filters – particularly how it appears in the Equation filter. What the effects of “Extend Modes” have on noise generated in the Equations filter. What the effects are of using the “a”, “y” or other equations in “y=” part of the Equations. Shows how noise equations can be used effectively on an empty pixel layer. Offers some practical uses for noise equations with macros. Introduction The aim of this tutorial is to explore the inner workings of the “noise” command as it’s used in the Equations filter in a practical and experimental way. I am not a computer programmer or a mathematician – so this is layman’s perspective, not a technical tutorial. The goal is to help users who have only a rudimentary understanding of the Equations filter get to grips with and find uses for the noise function in the Equations filter. Hopefully, any inaccuracies will be picked up by other users in comments. I’d like to thank John Rostron, whose more technical article about the noise function made me curious – you can read it on the forum HERE. Preparation If you want to follow in Affinity Photo the experiments I’ll make in this article, you’ll need to do the following: Open a test image or download mine – link at the bottom of the article. Make sure the image is a pixel layer not an image layer. If it says “Image” on the layer in the layer palette, right-click and select “rasterise…”. Duplicate this layer with Ctrl+J. Create a new pixel layer above the bottom Background layer and fill with a blue colour (eg. R:0, G:0,B250). This will enable you to see any transparent areas made by noise in the top layer. Noise vs Procedural Noise So, what is “Procedural Noise”? In digital imagery like digital photos and scanned images, noise is unwanted artifacts in the form of random variations in the colour and tone of pixels in an image, which are not part of the original image. They are generally produced as a result of electronic interference. If you push the ISO on your digital camera to its highest rating and take a photo in low light, zoom in and you will likely see spots, speckles and coloured patches which were not a part of the scene (see image below). A noisy image produced on a high ISO on an older camera. Usually (and mainly in photography) this noise is unwanted, but it can be used creatively for special effects or for artistic purposes by graphic designers and artists, so software like Affinity Photo usually provides effects filters which let the user add various forms of noise to their images. This noise is produced by a mathematical algorithm or piece of computer code, and so is made by a procedure – hence “Procedural Noise”. Here are couple of examples of procedural noise used artistically: In the image above, I used the Filters>Noise>Perlin Noise filter in combination with the Displace Filter for a quick artistic effect on the right-hand side – the left side is the original image. Both the background and the text textures in the image below were created using noise equations in the Equations filter. Affinity Photo provides the user with four main ways to introduce noise, all found in the Filters menu. Add Noise… and Perlin Noise… are found in the Noise section of the Filters menu. These are the simplest way to add noise, since they have a user-friendly interface. Noise can also be introduced through the Procedural Texture and Equations filters found in the Colours and Distort sub-menus. Both these require the user to enter equations, which can make them seem daunting, if not a no-go area, as there virtually no guidance on how to use them in the help file for those without any technical knowledge. If you want to begin understanding and using Procedural Textures in an accessible way, try my absolute beginner’s tutorials here – which also uses noise functions. Procedural Textures – Key Features The single most important/useful thing about procedurally produced noise is that it can be produced at any scale or resolution of image without degradation. Because it is a random pattern (pseudo-random, if we’re being pedantic) produced by an equation, the pixels it produces are not fixed or ‘real’ until the apply button is clicked. Instead, like vector graphics, the work at all sizes and scales of image. You can fill a 1mp or 100mp image with noise and the pattern will never repeat or degrade. One feature I have discovered, which is often overlooked, is that procedural noise is composed essentially of two areas: areas with the noise pattern and the areas between, which I am calling negative space. It turns out, the negative areas are just as important as the bits of noise, as we’ll see later. More precisely, it seems that there are parts (pixels, ultimately) which are solid colour, and others which are increasingly transparent – which become more evident when using noise in the Equations filter. Let’s take a look at very basic noise in the Equations Filter: Check to make sure the top layer of the test image is still selected. Open the Equations filter dialogue by going to Filters>Distort>Equations. Enter the following equation exactly as it is in the with no capitals or spaces: In the x= box type noise(x,y) In the y=box type the letter a (Which I’ll explain later). From the Extend Mode list, select Full. Coordinate System should be Cartesian, and Angular Units should be Degrees, by default – from now on everywhere I describe inputting an equation in the Equations dialogue the default settings of Cartesian and Degrees will be assumed. DON’T click apply, leave the dialogue open so you can follow the experiments below. To see the noise more clearly, hold down Ctrl and scroll your mouse wheel forward to zoom in. You can now see clumpy, fuzzy blobs of solid colour with fuzzy white patches of negative space. Zoomed out, it’s the coloured bits that we perceive as noise. I’ll explain the reason for the strange colour in a moment. What’s going on? What’s really happening is that the noise command generates random vertical and horizontal bars of tone shaded from white to a solid colour. We can see this by changing the equation. At the moment noise(x,y) is an instruction to make noise in the x and y directions - horizontally and vertically. Change the equation so that it reads noise(x,1). You should see random vertical bars in various tones of colour like this. Now change the x in the equation to a y, so the equation reads noise(y,1). You should see random horizontal bars in various tones of colour like this. This indicates that noise(x,y) is really a blend of the two. What the deal with the colour? When the noise(x,y) equation is used in combination with the Full noise Extend Mode, the filter generate noise which is a kind of average colour of the whole image, though this is not exactly the same colour as would be produced by the Blur Average filter. From my experiments, these white areas are, in reality, appear to be areas of transparent and semi-transparent pixels, depending upon the tone of the pixels. Pixels of the true averaged colour are opaque whilst lighter tones are increasingly transparent, until you get to white which is entirely transparent. At the moment, we are seeing the light pixels as white because, in this instance, the Extend Mode we’re using is Full, which makes the white areas opaque. I’ll explain a bit more about transparency later, when we look at other Extend Modes. There’s more than one kind of noise! Until now, I’ve been using the word “noise” to talk about procedural noise in general terms. In fact, in the Equations Filter the word “noise” is the name of just one particular type of noise. In the programming language used to generate procedural noise in both Procedural Textures and Equations, there are dozens of different types of noise (noise, noisei, noiseh, noisecubic, noisesin etc.), each producing a slightly different type of noise. The differences are, perhaps, more noticeable in Procedural Textures where you can magnify them to create interesting patterns, effects. You can see the full list if you look up Procedural Texture in the help file. Scroll down the page and you’ll eventually come to the lists of different noise types. For a very different kind of noise add the letter “i” after the word noise, so the equation reads noisei(x,y) in the x= box (till with a in the y= box and the Full Extend Mode). This makes noisei type noise, which is blocky and pixelated. noisei type noise Now try substituting the letter “i” with an “h”, so you have noiseh(y,x) in the equations. You should end up with something like this: noiseh type noise You can now clearly see the coloured fuzzy blobs of noise with the negative white areas between. Extend Modes make a MASSIVE difference Let’s prove that white areas and lighter tones are, in fact, areas of transparency. Just to remind you, Extend Mode is last option at the bottom of the Equations filter dialogue. It contains a drop-down list with Zero, Full, Repeat, Wrap and Mirror. Each mode has a different effect upon what the equation does to the image. Change the Extend Mode to Zero. noiseh(y,x) with Zero Extend Mode. Suddenly, you can see the underlying image (the blue layer) through a veil of noise. Experimenting with different extend modes To experiment with different Extend Modes, we’ll use the first noise equation we started with. It should still be open, but if it isn't, set it up the Equations dialogue as follows: That letter a in the y= box essentially activates the Parameter A slider, turning it into a sliding controller. I’ll come back to this later. Try testing out the Equations with different Extend Modes, at the same time as sliding the Parameter A slider back and forth. Here’s what I observed. Zero Extend Mode produces noise with transparent negative areas revealing the layer underneath the current layer. The noise pixels are made more transparent by sliding the Parameter A slider to the left. There is an initial brightening of the noise before it begins to fade, never quite going completely transparent. Full Extend Mode fills the layer with white overlain with noise. The noise pixels are made more transparent by sliding the Parameter A slider to the left. Repeat Extend Mode produces sparse noise (with this image) on a solid field of averaged colour. Moving the Parameter A make the noise and background colour lighter. Note: in one image, I found that the Repeat Extend Mode filled the layer with averaged colour and zero noise. Wrap Extend Mode is unpredictable from images to image. In the image, it averaged colour noise on a background which is the inverse colour of the noise. Moving the Parameter A to the left changes the relationship of the positive and negative colours, intensifying the background colour whilst making the noise more transparent. Mirror Extend Mode, gives identical results to Repeat, in these experiments. Dealing with the “y=” box So far, we have only had the letter a in the y= box. That is because the the y= equation box cannot be left blank. It must contain a value of some kind; either a letter*, a number, or another equation (which I’ll come back to later). If you enter the letters a,b or c in the y boxes then the A,B or C parameter sliders become active, giving customisable control of Equation depending upon which extend mode you use. *note: only letters that have a function in the Equations filter produce a result when used alone in x= or y= boxes. I will list other useable letters at the end of the article. However, if you leave the default letter “y” in the y equation field, you get completely different results with different Extend Modes. Try the following tests using noisei(x,y) in the x= field and y in the y= field. You’ll need to zoom out at little to get an idea of what is happening (hold down Ctrl and scroll the mouse wheel backwards). You should see something like this. Zero extend mode (above) produces random horizontal bands of colours which are averages of the area the bands cover. The negative, transparent and semi-trasparent areas of the noise pattern punch holes through the current layer revealing the layer underneath. Full extend mode (above) produces random horizontal bands of colours which are averages of the area the bands cover. The negative, transparent and semi_transparent areas of the noise pattern are white instead of transparent. You need to zoom in to see this more clearly. Repeat and Mirror, both produce random horizontal bands of colours which are averages of the area the bands cover with little or no noise. The Wrap Extend mode (above) is a weird one. It creates the same horizontal bands of colour, but this time, the negative spaces are of varying colour, perhaps inverse complimentaries? Using noise equations in both x= and y= boxes Adding a noise equation to the y= box in addition to the one in the x= box has the effect of adding a second layer of noise to the image. The resulting noise is now similar to the earlier noise where we put an a in the y= box. If the y= box contains the same equation as the x= then the effect, though, appears to be to increase the contrast between noise and negative areas. However, if equation in the x= box is noise(x,y) and the y= box is noise(y,x), the effect is to increase the overall amount of negative/transparent/white areas. What this means is that you can overlay two different kinds of noise, if you wish. Try for example, using noiseh(x,y) in the x= box and noiseh(y,x) in the y= box. This concludes Part 1 of the tutorial. Part looks at putting all to use with some practical examples. Scroll down for the link to Part 2. Notes Useable letters which can be use in the x= and y= boxes a, b & c – activate the parameter sliders in the dialogue h produces light, near neutral noise - Try h+a and h*a in the y= box with various modes. x & y Noises with the letter “h” in their name like (noiseh, noisehpsin, noisehcubic etc.) create harmonic noise, which has greater negative areas. Special note re. Perlin Noise Perlin noise, which you may have come across in the list of noise types, is a particular type of noise invented by Ken Perlin, who was looking for a way to generate more natural/realistic looking 3D textures. It has a more “clumpy” look to it. When it is scaled in 2D imaging software like Affinity it can create wonderfully versatile natural-looking textures from clouds to hair and even wood grain. Sorry to say, I have yet worked out how to scale any noise in Equations. Nevertheless is still a useful variation of noise. The Perlin noise command requires four pieces of information to work properly. I don’t want to go into any kind of technical depth here, so just try the example below (note the position of the Parameter A, B, and C sliders): Explanation: Perlinsin – a type of Perlin noise. rx,ry – generates the noise. The r before x and y means you can click in the image and drag the noise around. a*10 – Activates the Parameter A slider which seems to control softness and brightness b – Activates the Parameter B slider, which seems to control softness and graininess. /c/2 _ Activates the Parameter B slider, which acts as a sort of contrast control, change the spread of midtone pixels. GO TO PART 2