                         
                       Fading Mask Generation.
                       ~~~~~~~~~~~~~~~~~~~~~~

1. Introduction.
   ~~~~~~~~~~~~
	Since the very first photographers have produced vignetted prints. A simple way of doing this is to incert a shaped opake mask between the enlarging lens and the paper such that the image of the mask itself is "out of focus" and thus produced a blurred edge. Alternativly one could "sandwich" a specially prepared vignetting mask with the negative to get the effect required. Such masks could be purchased or made by the photographer and would be transparent (or cut out) in the centre and gradually change to opake at the edges. The resulting print would be "normal" in the centre and than fade to white. A "reversed" mask of this sort would cause the print to "fade" to black at the edges.
        When using digital image manipulation there may also be times when vignetting of this type may be required. Digital processing, however, opens up a considerably greater range of possibilities. The "fade" could be not only to white (or black) but also to any other colour, fuzziness, image reversal, various distortions etc. Some image editors (eg. Photoshop) provide facilities for vignetting but, as far as I know, none that work under Risc OS do so. I, therefore, decided to write my own software to do the job. It is not realistic, of course, to modify any existing image editor so the software had to be of a nature that produced files that image editors could import.
        What was needed, therefore, was a grey scale sprite file consisting of a white inner area outside of which were a succession of increasingly darker grey zones until black is reached. The user would determine the extent of the inner white area, the outer black area and the rate of change from white to black in between. There are three basic shapes that a user might want the mask to be:- Rectangular, Circular or Eliptical. The software provides for these three.

2. Method of Generation.
   ~~~~~~~~~~~~~~~~~~~~~
	This is really quite simple. It consists, basically,of drawing lines, the shape of the mask, at increasing distances from the inner clear area, each line being a darker shade of grey. In practice, in order to meet the user's requirements, there may be more than one line of a given shade of grey or a jump of more than one shade of grey between adjecent lines. However, since each line is just one pixel wide, when viewed overall or printed the line structure is not usually visible.

2.1 Rectangular Mask.
    ~~~~~~~~~~~~~~~~~
	The general geometry for a rectangular mask is shown in Fig.1.  Outside the thick line , having the dimensions W2 x H2,  the generated mask will be Black.  Between this and the Inner rectangle, having the dimentions W1 x H1,  there will be a gradual change from Black to White. This graduation is Linear - non-linear graduation is possible but a bit OTT. The idea is to form a large No. of recrangles between the Outer and Inner Limiting recrangles such that each is a shade lighter than the one outside it. The shade of grey used is simply in proportion to the relative position of the line between the inner and outer bounding rectangles. ie. if the line is half way between the two, the shade will be mid grey (index 128); if 20%, index 51 (a lighy grey); if 80%, index 204 (a dark grey) etc. It is arranged that where lines join on the diagonals, the shade of grey is maintained. In order to achieve this there has to be a restriction on the shape of the rectangular mask ie. the inner and outer bounding rectangles must be the same shape. To this end, the user may specify the width and height of the outer bounding rectangle but only the height of the inner. However, along the shorter (y) axis there may be fewer as some will "overlap".

2.2 Circular Mask.
    ~~~~~~~~~~~~~~
	The geometry here is simply that of two concentric circles.  Outside the larger is black and inside the smaller is White.  Between are a series of  concentric circles in shades of grey, the graduation being linear. Since the 'thickness' of each line cannot be smaller than a single pixel, there may be less than 254 greys with 'narrow' masks.  For 'wide' masks there will be more than one circle at any shade of grey.  To get exactly 254 greys the 'thickness' needs to be 254 pixels (approx. 2.8 cm when printed).

2.3 Eliptical Mask.
    ~~~~~~~~~~~~~~
	This is similar to the circular mask but, of course, eliptical.  The elipse may have its major axis either horizontal or vertical but if the latter it is restricted to 21.8 cm. (for larger vertical elipses generate horizontally and rotate in an image manipulation application).
     
The basic geometry is shown in Fig.2 below:-
           [ FadMasks.Images.HTML_Doc.Pic3 ]

The idea is to form a large No. of ellipses between the Outer and Inner Limiting ellipses such that each is a shade lighter than the one before it.  As with the Rectangular (& Circular) masks, the full 254 grey gradations will only be realised if the  'thickness' is 2.8 cm or more.


3. Application.
   ~~~~~~~~~~~
	The application I have written to produce these "Fading Masks" is called !FadMasks. Its output files may be used with image manipulation software, such as PhotoDesk, [ImageMaster ?, Paint ?].  They can be of various shapes - this application produces Rectangular, circular and eliptical masks.

	The output of !FadMasks is not strictly a 'Mask' but a grey scale image from which a mask can be made.  This image may also be directly combined with other images to give various effects (eg. vignetting).

The output is in the form of a Sprite which is 1024 x 768 pixels and always has a size of 788 536 Bytes.  If this is to be kept it should be compressed using !Squash or "Zipped" or as a GIF  file (but not as JPEG).  Typical size when compressed with !Squash is 96 kB and as a GIF  95 kB.

	For images smaller than 1024 x 768 pixels the mask should be made to the size required and then cropped. For larger images it is possible to enlarge the mask image within the image manipulation software, which works fairly well.	
For different effects the mask can, of course, be inverted.  Masks generated by this application always have Black at the outside and White at the centre.


3.0 File Saving.
    ~~~~~~~~~~~
The resulting Sprite is automatically saved to the Directory containing !FadMasks.  The Filename may be entered by the user.  If no File Leafname is entered the Default Name will be RESULT.  If a File Name, is entered which is already on the Log file, the resulting file will be called DUMP - unless it is already called RESULT.

The Log File is a Text File and may, of course, be "Cleared" by simply erasing all of the text before the "\" , which must be retained (along with the Title).















































										Page 4

