Translated by google :

Arithmetic Module

Copyright (c) 2003-2004 Benjamin FOURNIER

Version 2.2.3 with multi-language icon

Original language: English

Additional languages: French

For information on this plugin:

pluginsphotofiltre@yahoo.frTranslation

==========

If you want to translate this plugin in a different language please send me an e-mail to

pluginsphotofiltre@yahoo.frIf you want to translate this plugin in another language please send me an e-mail to

pluginsphotofiltre@yahoo.frLicense

=======

PhotoFiltre license shall apply to this plugin (except the fact that there is no specific record for this plugin)

Description

===========

Plug-in (plugin) for PhotoFiltre

Copyright (c) 2001-2003 Antonio DA CRUZ

Website:

http://www.photofiltre.comUsed to perform arithmetic between multiple images and / or colors

Installation

============

Unzip the file 'Arithmetique.pfl' in the 'Plugins' of PhotoFiltre.

Then restart PhotoFiltre to load the module.

Use

===========

This module is a module of type tool

it appears in the Tools / Other as the arithmetic ...

This module is only available if there is at least an open image.

Just write the desired expression (eg (I1 + I2) / 2) by using operators, functions, colors and images. To insert a picture just double click on the following image in the browser at the bottom of the window. After writing you can click Preview to see the result. Once you are satisfied, just click OK to generate the new image result.

Problem with color syntax

================================

If you have problems with the plugin arithmetic there is a good chance that this is the control to obtain the syntax colored. You can disable it by adding the following line in the [Plugin Arithmetic] File PhotoFiltre.ini:

[Plugin Arithmetic]

PasDeSyntaxe = 1

Writing expressions

========================

All operations can be written using the buttons or typing on the keyboard completely.

An expression consists of:

---------------------------

- Images: they are indicated in the expression as I <n> with n between 1 and the number of open images. The number corresponds to that shown in the image browser. An image is inserted by double clicking in explorer image.

- Color: they are indicated in the expression in the form # RRGGBB in hex decimal (equivalent to the HTML code of a color). A color can be inserted by clicking the colored button.

- Number of integers: they are typed on the keyboard and must be understood in -2147483647 and +2147483647 (signed 32-bit precision)

- The usual four operators: + - * / As in a conventional arithmetic expression, multiplication and division take precedence over addition and subtraction. Division by 0 is not considered an error but the infinite bounds are used as follows:

if n> 0: n / 0 is 2147483647

if n <0: n / 0 is -2147483647

if n = 0: n / 0 is 0

- The operator stating: ^ which yields the square, cube etc..

- Modulo the: mod that allows for the remainder of the integer division

- Tests of six operators: = <> <> <=> =

They are especially useful with the IF function but can be used as-is. The operators return 255 (white) when the condition is true and 0 (black) otherwise.

- Or binary logic functions: and or xor not

They are especially useful with the IF function but can be used as-is.

- In parentheses, as in a conventional arithmetic expression they allow to force operator precedence.

- Single-line comments with / /

- Other functions:

Max (x1, .., xn): Takes the maximum argument for each RGB component

For example:

-------------

Max (# FF0000, # 00FF00, # 0000FF) gives # FFFFFF

Min (x1 ,..., yn): Takes the minimum of the argument for each RGB component

For example:

-------------

Min (# 00FFFF, FF00FF #, # FFFF00) gives # 000000

MaxLum (x1 ,..., yn): Takes the brightest color

For example:

-------------

MaxLum (# FF0000, # 80FF00) gives # 80FF00

MinLum (x1 ,..., yn): Takes the least luminous color

For example:

-------------

MinLum (# FF0000, # 80FF00) gives # FF0000

Avg (x1 ,..., yn) <=> (x1 +...+ yn) / n

AvgRGB (x): Returns the average of the three RGB components that can transform a color image to grayscale

Lum (x): Returns the luminance of the three RGB components with 0.299R + 0.587G formula + 0.114B

RGB2HSL (x): Converts an RGB color to its equivalent HSL

HSL2RGB (x): Converts an HSL color in RGB equivalent

RGB2YUV (x): Converts an RGB color to the equivalent YUV

YUV2RGB (x): Convert a YUV color in RGB equivalent

R (x): Returns the red component

G (x): Returns the green component

B (x): Returns the blue component

Abs (x): returns the absolute value useful for comparing images

Root (x [, n]): Returns the nth root of x. If n is not specified it is the square root.

If (<condition>, <true>, <false>): This function allows for conditional tests on the points of the images.

For example:

-------------

If (I1> I2, # FF0000, # 00FF00) gives a red and green where red dots represent the points of I1 which are brighter than those of I2 and where the green dots represent the points of I1 which are less luminous ( or as bright) than I2.

X (x): Returns the X coordinate of the image that allows for horizontal gradients

Y (x): Returns the Y coordinate of the image that allows for vertical gradients

W (x): Returns the horizontal size of the image (useful for reversing a horizontal gradient)

H (x): Returns the vertical size of the image (useful for reversing a vertical gradient)

Stretch (x, y): x Scales the image to the image size to

BStretch (x, y): Same Stretch but with bilinear filtering.

Tile (x, y): x Scales the image to the size of the image by copying the image it as many times as necessary to achieve this size.

Scroll (x, dx, dy): Shifts the image of a certain number of pixels ... What disappears on one side reappears on the other

dx indicates the horizontal offset (negative = left, positive = right)

dy indicates the vertical offset (negative = top, bottom = positive)

Note that the offset is not necessarily the same for all parts or components of the images.

For example:

-------------

Scroll (I1, W (I1) / 2, H (I1) / 2): Shifts the image in order to reverse the four corners

Scroll (I1, Y (I1), 0): Offset progressive line (the first is not shifted, the last of the image height - 1)

Scroll (I1-X (I1)-Y (I1)): Division of the image size by 2 and type extension pattern

AlphaBlend (x, y, mask, max): alphablending between the image x and y using the image mask and specifying the maximum in order to reverse the mask.

For example:

-------------

AlphaBlend (I1, I2, X (I1), W (I1))

Allows for a fade between the artistic image I1 and I2 image

- Variables:

The variables used to decompose a complex expression into several parts. This will also avoid performing the same operation several times which also speeds up processing times.

A variable is an identifier must begin with a letter or character '_'. The numbers can be used from the second character.

Declare a variable:

----------------------------

<Variable Name>: <Expression>;

Using a variable:

----------------------------

<Variable Name>

Swapping images

======================

The drag & drop is available on the list of image which allows to reorder the images (which may be more convenient than changing In the expression)

The drag & drop using the right mouse button.

Miscellaneous information

=====================

All operations on the images are made with 32-bit integers for each of the RGB components. The operations are applied individually to each of the three components.

An integer is considered a color in which all components are identical (gray level). For example, the integer is equivalent to 10 color # 0A0A0A.

When a transaction involves two images of different sizes the images are resized to the largest size possible as and when evaluating the expression.

When an error is detected in the expression an explicit error message indicates the part of the expression is misplaced (or unexpected token) and the list of possibilities (or possible token) at this place of expression. The cursor is placed after the part of the expression wrong.

Spaces, tabs and newlines can be used to separate the elements of the term (example: I1 + I2)

Examples of expressions

======================

It is assumed that 3 images are open:

- Average of first two images:

(I1 + I2) / 2

or

Avg (I1, I2)

- Remove a component of the first image:

* Red:

# 010000 * I1 or I1 and # FF0000

* Green:

# 000100 * I1 or I1 and # 00FF00

* Blue:

# 000001 * I1 or I1 and # 0000FF

- Sum of the red component of an image with the green component of the image 2 and the blue component of the image 3

I1 + I2 * # 010000 # * # * I3 + 000 100 000 001 or (I1 and # FF0000) + (I2 and # 00FF00) + (I3 and # 0000FF)

- Doubling the light intensity of an image

I1 * 2

- To the square of each component of the image

I1 ^ 2

- Making a difference in two images:

* Get a binary image with white spots where the black pixels are different and if (m has been useful to check my algorithm of lossless jpeg)

If (I1 = I2, 0.255) or if (I1 <> I 2, 255.0)

* Get the real difference with the resulting color

Abs (I1-I2)

Note: The decimal numbers are not available but it is possible to circumvent the problem using fractions:

- Multiply by 1.5 the brightness of an image

(I1 * 3) / 2

Note: Parentheses are not required here

- Make a horizontal grayscale image suitable for:

X (I1) * 255 / W (I1)

or the other way:

255 - (X (I1) * 255 / W (I1)) or (W (I1)-X (I1)) * 255 / W (I1)

- Make a grayscale image suitable for vertical:

Y (I1) * 255 / H (I1)

or the other way:

255 - (Y (I1) * 255 / H (I1)) or (H (I1)-Y (I1)) * 255 / H (I1)

- Make the tutorial of the fade landscape / portrait:

This form is sufficient:

AlphaBlend (I1, I2, X (I1), W (I1))

with I1 and I2 the portrait the landscape!

Examples complete with variables, functions, comments ... :

================================================== ============

A: Max (W (I1) / 4, H (I1) / 4) / / radius central

C: Root ((X (I1)-W (I1) / 2) ^ 2 + (Y (I1)-H (I1) / 2) ^ 2) / / Circle gradient

C: If (C <R, 0, CR) / / Set the central black

M: Max (W (I1), H (I1)) / 2-R / / Maximum to reverse the mask

IC: M-C / / Invert the mask

(# 0080C0 * C * IC + I1) / M / / Alpha blending with color

I1 is an image such as the panther used in the tutorial text and image of the official website.

Assemmblage art between two images:

=======================================

F: 64 / / Size of the common area

H: Max (H (I1) H (I2)) / / Maximum height of 2 images

S1: BStretch (I1, W (I1) * H / H (I1), H) / / Adaptation of the height for an image

S2: BStretch (I2, W (I2) * H / H (I2), H) / / Adaptation of the height for the image 2

W: W (S1) + W (S2)-F / / Image size Total

T1: Tile (S1, W, H) / / Increase the area of the image a Trevail

T2: Scroll (Tile (S2, W, H), W (S1)-F, 0) / / Increase the area of the image Trevail 2 and positioning the right place

If (X (T1) <W (S1)-F, T1, / / Image 1

If (X (T1)> W (S1), T2, / / Image 2

AlphaBlend (T1, T2, X (T1)-W (S1) + F, F))) / / Fade

Good use!