Search the Community
Showing results for tags 'equations'.
Found 20 results

Wrapping a label round a bottle or mug in Photo
John Rostron posted a topic in Tutorials (Serif and Customer Created Tutorials)
In a recent post in Questions, @Maxxxworld asked how he could warp an image to apparently wrap it around a bottle. I posted a solution to his problem there, which I expand upon here. Consider the facing semicircle of the bottle as seen in this diagram: The visible part of the label extends from 90 degrees (on the left, not shown) to 90 degrees on the right. This will correspond to the width of the original image. This will project onto the final width of the image (the line below). The final width is less than the original width by a factor of pi/2. A bit of trigonometry shows that the sine of the Angle indicated is given by (xhalfwidth)/halfwidth, where halfwidth is both the label and the final image. Putting this together and rearranging a bit gives us an Equation: x=(asin(2*x/w1)*w/180)*pi/2+w/2 A bottle is typically viewed from above, so that the label has a curve, typically with a dip in the middle.This can easily be simulated using equations, using: y=yConst*x*(wx)/w/w The Constant determines the depth and direction of the curve. I have used the expression w*(0.5a) as a scaling factor, where a is a parameter chosen at runtime. This will change the curve from negative (curving down) at the default a=1 to positive at a=0. Inserting this into the equation gives: y=y+(0.5a)*x*(wx)/w Note that the w in the numerator and denominator cancel out. The value of (0.5a) determines the curvature as described above. As an example, here is the Great West Window of Chester Cathedral. I chose this because it has lots of verticals to see how the filter affects it. (It has verticals once I had put it through the Mesh Warp.) And here is the image after the filter: Before filtering I cropped it close to the sides of the window and then Rasterized it to remove the invisible sides. I then added space at the top and bottom to allow room for the curvature part to operate. I then followed this by Clip Canvas to remove surplus transparent ends. The calculations for this filter are complicated by the algorithm that Affinity uses to effect these equations, which I explain in this Tutorial here. I have created a macro that effects the filter, and then uses Clip Canvas. By clicking on the cogwheel, you can alter the degree and direction of curvature. WrapAround.afmacro John 
Modify image RGB values in equations
PDB Jones posted a topic in Suggestions for Affinity Photo on Desktop
I would ,like to be able to modify image RBG values based on combination of: a) neighbouring RBG values; b) user parameter inputs. I light to experiment with various colour abstractions of my images. I have not found any expressions in help material, or corresponding forum answers. Is this something already available? If so, where? Otherwsie could this capability be added to the equations/expressions capability of Affinity Photo. 
Vexillomorphic transformations (FlagWaving) in Photo
John Rostron posted a topic in Tutorials (Serif and Customer Created Tutorials)
This is an extension of my tutorial on Trigonometrical transformations using Filter > Distort > Equations. This one is focused on simulating flags waving in a light wind. Flags have an advantage in that they have a standard shape (width is twice the height). Edit: I have been told that this is not true. I stand corrected. To get the desired waving, I apply a sine transformation to each of the x and yaxes. The equations to apply are: x=(x+20*sin(360*y/h))/c100*b y=y+a*(h/10)*sin(2*360*x/w)(x/w)*h/10 I add a sideways sine wave to the xaxis as a function of the yposition. When the flag waves, the visual width is decreased, so I have added a parameter c which scales the width of the flag. The parameter b is an offset, since the lefthand corners of the flag can otherwise move outside the canvas. The yaxis also has a sine wave, depending on the xposition. The parameter a determines the magnitude of this sine wave. The final expression ((x/w)*h/10) ensures that the fly (RHS in this case) is below the hoist (LHS here). (Definitions: hoist is the part next to the flagpole; fly is the part flying free.) Here is the UK Union Flag, plus a bit of extra space above and below to create room: And waving in the breeze: And here is a macro that implements these transformations: FlagWaving.afmacro The parameters should appear when you run the macro. Parameter a controls the vertical wave; parameter b controls the horizontal offset; parameter c controls the overall horizontal scaling. This macro will not simulate a flag in too strong a wind, where the parts overlap! John 
Rotating a Document using Equations in Photo
John Rostron posted a topic in Tutorials (Serif and Customer Created Tutorials)
Many options for rotation in Affinity Photo are constrained to simple fractions of a circle, with 15 degrees being the smallest. It is possible to rotate by an arbitrary angle using the Crop tool. You place the cursor just outside a corner, and rotate by dragging the twoarrowed cursor that appears. This tutorial explains how you can rotate an image using Filter > Distort > Equations. Before rotation you would normally want to expand the canvas so that you can give the document enough room to rotate. The new canvas width should be at least 150% of the existing diagonal and the Anchor should be in the centre of the array of nine positions. See this image: q Now select Filter > Distort > Equations. The top pair of buttons allow you to choose the coordinate system. The default is Cartesian (the usual x and y axes). You need to choose the Polar option. You now have two lines: r=r t=t The r represents the radius (the distance of a point from the centre of the image), and the t (or Theta) is the angle of rotation in radians.Radians are a measure based on pi, You can easily express an angle in radians as a multiple of pi, so 2*pi represents the entire 360 degree rotation, pi represents a halfcircle rotation (180 degrees) and pi/4 represents a quarter of a half circle, or 45 degrees. So, writing t=t+pi/2 rotates the image by a quarter of a circle counterclockwise. Entering t=tpi*0.333 rotates it by a sixth of a circle clockwise. So, given a grid like this (after resizing the canvas): and using the equations as above, gives an image like this: which can then be clipped (Document > Clip Canvas) to give: . I have created a macro with a single parameter a which represents the fraction of pi. The default value of 1 will not rotate the image. Increasing a will give progressively more rotation; a value of 0.5 will rotate by a halfcircle. In the example here, I have resized the canvas before applying the macro. The formula used in this macro is: t=t+pi*2*a. Here is the macro: Rotate.afmacro John 
Distort > Equations: How it works
John Rostron posted a topic in Tutorials (Serif and Customer Created Tutorials)
I recently had difficulty in getting the Distort > Equations Filter to work as I thought it should, I was convinced that there was an error and posted a Bug report here. After comment from members @shojtsy and @walt.farrell and moderators @Andy Somerfieldand @Patrick Connor, I finally got it sorted. I thought that an item in the Tutorials might help for others coming to this problem anew. Consider a simple pair of Equations: x=x+y*0.2 y=y*0.7 My original thoughts were that these represented algebraic transformations, that the value of the pixel at position (x,y) would be moved to pixel position (x+y*0.2, y*0.7). Applying this to the image: gives: The bottom right corner of the image is transparent. My expectation was that the height of the text would be reduced to 70%, but it is actually expanded to approximately 140% (1/0.7). I originally expected the slant to be anticlockwise, but it was clockwise. My original thoughts and expectations were wrong. What actually happens is quite different. For any pixel at position (x,y), Affinity Photo will find the pixel at (x+y*0.2, y*0.7) and use the value of the pixel value there to apply to the pixel at (x,y). Following this logic, the results are consistent with (revised) expectations. John 
From previous experience, the y parameter in Distort > Equations goes from top to bottom, as with most graphic programs. I have always assumed this in constructing equations and macros. Recently I have been doing some experiments. This is the base image I have started with, allowing around 25 pixels underneath the rasterized text: I then use y=y+20 and get: and then using y=y20 to get: which both behave as if the yorigin is at the bottom. I then try multiplying and dividing by a fraction. Firstly y=y*0.7 to get: Then y=y/0.7 to get: These seem to behave in the opposite way to what one would expect. Multiplying by a fraction 0.7 enlarges the image and dividing by 0.7 shrinks the image (leaving a gap at the bottom). These both behave as if the yorigin was at the top. I have tried these in both the current version of Photo and the most recent Beta with the same results. Resolved: it is not a bug. I have posted a Tutorial summarising the resolution of this as a Tutorial. John

Using Equations in Distort  Convert to Polar
John Rostron posted a topic in Tutorials (Serif and Customer Created Tutorials)
Conversion of a rectangular image to polar coordinates using Equations is not straightforward. A major problem is that the origin of the rectangular Cartesian coordinates is the top left, whereas for a polar display, you would typically want the origin on the midline, probably near the bottom. The following equations assume that the origin is in the midline along the xaxis, and at or near the bottom on the yaxis. First select Filter > Distort > Equations and enter: x=w*atan((xw/2)/(h/ay))/100+w/2 y=hsqrt((xw/2)^2+(hy)^2) The expression (xw/2) displaces the horizontal origin to the centre, and the expression (hy) displaces the vertical origin to the bottom. In the first formula, for x, there is a parameter a, which allows you to scale the polar transformation; reducing the parameter a stretches the image around the circle. The 100 is an arbitrary scaling parameter which seems to work. The expression +w/2 at the end recentres the image. This seems to be necessary, but I am not sure why. I would have expected to deduct w/2 rather than add it! Here is an original image of the Quantum Leap statue in Shrewsbury: With this transform using the default parameter a, this produces a quadrant. And with the parameter set to approximately 0.6: Here is the Macro: PolarQuadrant.afmacro The first thing the macro does is to unlock the image. I tend to do this automatically in macros. It is probably unnecessary. I ought to be able to give the adjustable parameter a, a name, but I have not been able to do this. John 
Using Equations in Distort  Parameter won't work
John Rostron posted a topic in Affinity on Desktop Questions (Mac and Windows)
@atfitzy posted a thread about reshaping a text block. I tried various Equations in Filter> Distort and the best I could come up with is: x=x y+(hy)*(wx)*x/w/w/a This produces the required arch in the upper margin of the block. The a parameter allows the user to increase the stretching effect. The default of one has no effect; reducing it will increase the effect. However, I find that reducing the parameter has no effect until the value goes below half, after which it has the desired effect. I can get the desired effect by putting a multiplier at the start of the equation: y+2*(hy)*(wx)*x/w/w/a Here are a couple of arched images using this formula: Otherwise the formula works as desired. Before I commit this to a macro can anyone explain this unexpected behaviour in the parameter value? John 
I have been trying to use the Filter >Distort > Equations to perform a simple Perspective correction. However when inserting formulae into the Equations filter, it seems to act on the wrong axis. I therefore tried a much simpler pair of formulae: x=x100*(1a) y=y100*(1b) By default there is no change, since the default parameter value is 1. If I reduce parameter a, a transparent area appears at the top of the image, increasing as I reduce parameter a. If I reduce parameter b, a transparent area appears at the right of the image, increasing as I reduce parameter b. So, the formula for the xaxis affects the yaxis, and the formula for the yaxis affects the xaxis. John

I have been using Filter > Distort > Equations to modify text onto a sine curve. First I rasterize the text, then apply Filter > Distort > Equations with the following formulae: x=x y= y+(h*a/2)*(b*sin(360*x/w/c)+(1b)*cos(360*x/w/c)) This filter works as intended as a oneoff, and whilst recording the macro, but If I then export the macro, and try to apply the macro later nothing happens. The history panel shows that it has been applied, but the image is unchanged. This happens whether I load the macro as a single macro, or if I add it to a library and load it from there. What seems to be happening is that when I record, I set the parameters a, b and c to 0.25, 1 and 1 respectively. The default in each case is 1. When I try to execute the macro, the parameters b and c seem to have been reset to zero which means that the macro is unusable, since dividing by c means dividing by zero. I can use the Macro Edit facility to apply valid values, but this should not be necessary. Text onto sinecosine curve.afmacro John

Macro records but will not perform
John Rostron posted a topic in Affinity on Desktop Questions (Mac and Windows)
I have been using Filter > Distort > Equations to modify text onto a sine curve. First I rasterize the text, then apply Filter > Distort > Equations with the following formulae: x=x y= y+(h*a/2)*(b*sin(360*x/w/c)+(1b)*cos(360*x/w/c)) This filter works as intended as a oneoff, and whilst recording the macro, but If I then export the macro, and try to apply the macro later nothing happens. The history panel shows that it has been applied, but the image is unchanged. This happens whether I load the macro as a single macro, or if I add it to a library and load it from there. Text onto sinecosine curve.afmacro Anyone any ideas? John 
Using Equations in Distort  Trig functions
John Rostron posted a topic in Tutorials (Serif and Customer Created Tutorials)
The equations facility in Affinity is not well documented. There is limited support in some AP actions, but the Transform and Distort > Equations filter offers a wide range of functions. This tutorial focuses on using the trigonometrical functions, sine, tangent and arctangent. The argument to many trigonometrical functions is an angle. In mathematics this is usually expressed in radians. However, the Affinity functions expect their argument in degrees. Sines and cosines The argument expected is in degrees, and over 360 degrees, the value of the function varies between 1 and +1. The sine function starts at zero and rises to a maximum at 90 deg, then falls to zero at 180 deg, falling to a minimum of 1 at 270 deg before rising to zero at 360 deg. If we wish to map this cycle to the width of an image, then we can use sin(360*x/w). Typically we would want the amplitude of the cycle (the maximum and minimum) to be more than 1 and 1, so we add a scale factor, measured in pixels. For an amplitude of 100 pixels, we have 100*sin(360*x/w). This gives one cycle across the width of the image. If we want more than one cycle, we can add a multiplier in the argument, so for three cycles per width, we can use 100*sin(3*360*x/w). Note that I use 3*360 rather than 1080 since it preserves the standard 360 multiplier. As an example, here is a checkerboard with Filter > Distort > Equations: x=x y=y+100*sin(2*360*x/w) If we apply this to a real image, we get: This is varying the vertical position of a point along the xaxis. We could vary the vertical position of a point along the yaxis by using the equation: y=y+100*sin(2*360*y/h) For the checkerboard, this would give: And for the Severn Bridge we get: We could even combine them both with the formula: y=y+100*sin(2*360*x/w)*sin(2*360*y/h) to give: or, for a real image: I will be adding further examples using tangents and cotangents. 
Equations  a general comprehensive overview?
Jurgen posted a topic in Affinity on Desktop Questions (Mac and Windows)
Hello there, in the tutorials equations are mentioned a few times, like in the Macros videos. But there is no general overview of the functions that I am aware of  for instance, relative to noise the video mentions that there are 4 different noise generators but I didn't find specific explanations as to possibilities using equations. Is there anything? I'd be glad to go through it... 
Information needed about Equations
John Rostron posted a topic in Affinity on Desktop Questions (Mac and Windows)
I have been trying to devise a macro using the Distort > Equations, but it is hampered by a lack of documentation. I recall having once seen a list of supported functions, but I cannot now locate it. Neither Affinity help, this forum nor even Google have revealed this. I assume the same engine will apply to Transform using Equations. Can anyone please tell me where it could be found? 
When using Apply Image equations, I am expecting to see a completely greyscale image when Da and Db are set to constant 0 in LAB space, however I see a heavy blue tint. See attached screenshot, left side should be greyscale instead.
 3 replies

 ap
 apply image

(and 1 more)
Tagged with:

Solar Eclipse Image Processing w/ Photos
tradesmith45 posted a topic in Affinity on Desktop Questions (Mac and Windows)
First post here. I've been working on a composite of images captured during totality & getting some banding artifacts in PS when forced to use 16 bit mode rather than 32 bit for sharpening steps. I'd like to make sure Affinity Photos has the adjustments I need in 32 bit mode. The complete workflow for PS is describe in this tutorial by Russell Brown: PS Spin Blur Eclipse Processing From Photos tutorials, I see there are spinblur filters, Apply Image: Equations panel & an Equations panel. So maybe everything I node is there but done differently in Photos. The key step I'm unsure about is in one of the equations panels. In PS, a duplicate image is spin blurred & the alpha channel of that image is subtracted from the original alpha w/ an offset of 128 in the Calculations panel to give a low contrast midgray frequency mask. That mask is then Overlayed onto the original. I'd like to confirm that all this can be done in Photos in 32 bit mode? Here is a version of my PS work from 77 images w/ artifacts & a mask. The frequency mask reveals the finer corona detail. Thanks! 13 replies

 solar eclipse
 equations

(and 4 more)
Tagged with:

Blendingrelated wish list: Adding "Use beneath layers as initial Destination" button in Apply Image filter.Such button would allow for typical use case when you want to perform custom blending. Nowadays you have to: temporarily hide the layer "S" you want to blend, Merge Visible, unhide the layer "S" and move it below new merged layer "D", switch to layer "D", Apply Image and drag layer "S" onto its dialog window to use it as Source. Supporting presets for equations in Apply Image.It's obvious enhancement for better automation. Defining custom blend mode via Adjustment Layer (possibly called Blend Adjustment).It would work for such layer only when it is a child layer. Presets here are also crucial. Defining custom global (accessible in all documents) or local (accessible in current document) blend modes.The most robust solution for users performing repeatedly their own custom blending. In Blend Mode Manager there should be a way to see (in a readonly manner) already existing blend modes with equations (for blend modes expressable in plain equations). Blend mode definition should be performed using equations where:S (Source) = current layer [aka Active or A] D (Destination) = beneath layers [aka Background or B] In case of Blend Adjustment source would be the parent layer. Example of custom blend mode: Remove DR=(DRSR*SA)/(1SA) DG=(DGSG*SA)/(1SA) DB=(DBSB*SA)/(1SA) DA=DA(It doesn't make sense for truly opaque layer, of course.)
 1 reply

 blend mode
 apply image

(and 2 more)
Tagged with:

Does someone know how to implement FloydSteinberg or Jarvis, Judice, Ninke dithering with equations? Is that even possible at this point?

Equations filter not working??!!
fatkangaroo posted a topic in Affinity on Desktop Questions (Mac and Windows)
Hi all This is a bit embarrasssing but, curious to explore features, I went to try the Equatons filter and I can't get it to work!! I am applying it to a plain simple jpg  nothing! I am using Photo 1.5.0.45. HELP!! :) Adam 
Trying out the awesome new Equations feature in "Apply Image", I found that expressions that lead to outofbounds values are not handled gracefully (8bit mode). My test was a simple color difference greenscreen keyer: DA = SG  max(SR, SB) The result has artifacts where this expression yields negative results. Doing the clamping manually works fine. DA = max(0, SGmax(SR, SB)) It would make more sense to always have this clamping performed automatically and implicitly for nonfloat documents. This would also ensure that more expressions and macros created for unbounded floating point images will work with 8bit and 16bit documents without adjustments. I have also not been able to find out how to access the current pixel's coordinates inside Apply Image (seems to work for "Distort > Equations" expressions) and what the syntax for modulo operators is, but that's likely either due to my stupidity or it not being implemented yet and not a bug. Also, I noticed a strange 1pixel diagonal line pattern when choosing a source layer and then navigating to an adjustment layer in the Layers panel.

 Apply Image
 Expressions

(and 2 more)
Tagged with: