| <<< Home | << Web | < Arithmetic | Top | Bottom | < Prev | Next > |
Subtraction is done using the following formula:
(a,b,c) - (x,y,z) = ( (a-x)/d + i , (b-y)/d + i , (c-y)/d + i)
where d is the divisor and i is the bias. The bias can be positive or negative.
Subtraction is the only arithmetic operation where it matters which image is first and which is second. Subtracting image 1 from image 2 gives a very different result from subtracting image 2 from image 1.
Difference is similar to subtraction, except that the values a-x, b-y and c-y are replaced with their absolute values (in other words, if a result is negative it is made positive). Unlike subtraction, you'll get the same result no matter which image is first and which is second (except, of course, that if the images have different sizes, the size of the first image controls the size of the result).
When using subtraction or difference, you will generally use a divisor of 1 and a bias of 0. As usual, though, you will want to experiment a little with these values. Often, a positive bias value may improve the result. If you get a result that's a bit too dark or too light, don't forget that you might be able to turn it into a nicer image using PSP techniques such as gamma correction or brightness/contrast adjustment.
When using subtraction with divisor 1 and bias 0, the resultant values will be in the range -255 through 255. If you specify clipping, all negative values are set to zero. Otherwise, negative values wrap around by adding 256 (2, 1, 0, 255, 254 ...).
When using difference with divisor 1 and bias 0, results are always in the range 0 through 255. You don't need to worry about clipping unless you use a non-zero bias.
When using divisor 1 and bias 0, black (0,0,0) is special:
For both subtraction and difference, (anycolor - black) leaves anycolor unchanged.
For subtraction, (black - anycolor) is black if you specify clipping.
For difference, (black - anycolor) leaves anycolor unchanged.
Here are some examples using divisor=1, bias=0:
| Value 1 | - | Value 2 | = | Clipped | Unclipped | Difference |
|---|---|---|---|---|---|---|
| (0,0,0) | - | (127,0,0) | = | (0,0,0) | (129,0,0) | (127,0,0) |
| (0,0,0) | - | (0,32,200) | = | (0,0,0) | (0,224,56) | (0,32,200) |
| (255,0,0) | - | (0,255,0) | = | (255,0,0) | (255,1,0) | (255,255,0) |
| (255,0,0) | - | (0,0,127) | = | (255,0,0) | (255,0,129) | (255,0,127) |
| (255,255,255) | - | (88,48,104) | = | (167,207,151) | (167,207,152) | (167,207,152) |
| <<< Home | << Web | < Arithmetic | Top | Bottom | < Prev | Next > |