Skip to content

Processing_Digitised_X ray_Images

John Cupitt edited this page Mar 29, 2017 · 1 revision

title: Processing Digitised X-ray Images permalink: /Processing_Digitised_X-ray_Images/

Origin

This page has been written as part of the NIP2 Beginners Guide.

Background and Summary

Before I start to describe how this process works I would like to say that it is much easier to do than it is to explain. :-)

The X-ray examination of paintings can produce rather complex images containing information relating to the entire 3-dimensional structure. Although all of the information recorded can be useful, it is not always helpful to display it all at once. One of the most disruptive elements to the readability of the X-ray of a painting is the tonal difference or 'shadow' caused by the painting's secondary support, i.e. stretchers, cradles, etc. The following functions have been produced to allow the semi-automatic removal or balancing-out of these tonal differences. The process can be performed on scanned versions of existing X-ray plates[#note64\ 1] thus removing the requirement for paintings to be re-x-rayed under special conditions.[#note65\ 2] These functions will take an original X-ray image, a control mask[#note66\ 3] image and a group of other mask[#note67\ 4] images, process them and produce a semi-automatically balanced image. It should be noted that for larger images and larger sets of masks this process can take a while, several minutes plus, depending on the speed of your computer. The process is achieved by comparing the average pixel values of each area defined by each mask, with the average value of the area defined by the control mask. The software then individually adjusts each of the defined areas to match the control area and then blends then all together, along with the original image to produce the final balanced image.

Mask Images

sec:mask In the context of this document, a mask is a new image used to define specific areas within an original image. In this case the original image will be a completed X-ray mosaic. Mask images are produced by taking a copy of the original image, outlining an area of interest, filling in the defined area and then deleting the rest of the image, see figure [#fg:canvas_masks 7.1]fg:canvas_masks and figure [#fg:panel_masks 7.2]fg:panel_masks. For this process, the mask images all need to be the same size as the original image, pixel width and height, and the areas of interest will be represented as white shapes on a black background. It should be noted that single Mask images can define multiple areas within the image, for example one Mask may define several different stretcher keys. The Control Mask is a special mask which defines a control area of the the original X-ray mosaic. The areas of the image you wish the rest of the image to match, i.e. the areas not affected by the secondary support, stretcher, cradle, etc.

Resizing Files Before Processing

sec:resize_xray Digital X-ray composite images can become very large, for big paintings they can easily become more than 1GB in size [#note68\ 5]. Carrying out complex image processing operations on images of this size can take quite a while. In order to speed up the process the manual balancing functions provided in nip2 have been separated out into three stages; find, check and apply. The first two stages can be carried out using a small version of the X-ray image and once that has been successfully balanced the calculated values can then be directly applied to original large version of the x-ray image, without having to redo all of hte calculations.

Summary of steps required to produce a balanced X-ray composite:[#note69\ 6]

  • Ensure you have a complete set of X-ray plates for your painting, or a subset that cover the area you are interested in, and make sure you have a reasonable overlap between all of your X-ray plates.[#note70\ 7]
  • Digitise all of your X-ray plates to produce a set of images of the required size and quality, see section [#sec:xray_res 7.2.1]sec:xray_res.
  • Mosaic the images together together using the Two tie-point mosaicing functions as described in section [#sec:mosaicing 6.3]sec:mosaicing and then save your completed X-ray mosaic.
  • Produce a small version of your image, about 2-3000px in width using the resize functions, see section [#sec:nipresize 5.9.4]sec:nipresize.[#note71\ 8]
  • Select and produce a complete sets of masks from the small version of your X-ray image, see section [#sec:mask_production 7.4.1]sec:mask_production.
  • Perform the first two stages of the balancing process and produce balanced version of your small image using the masks and the small image, see section [#sec:man_bal 7.5]sec:man_bal.
  • Then apply the results of the first two stages to the original full size x-ray to produce a full size balanced x-ray, see section [#sec:man_bal 7.5]sec:man_bal.

Digitising original X-ray Plates.

When it comes to scanning it is always best, if possible to scan negatives rather then positives and original objects rather than copies. This is to ensure that the maximum amount of information is available without distortion and loss of scale information. Using a flatbed Scanner, with a transparency adaptor: These products come in a large number of shapes, sizes and, of course, prices. Ideally you want a scanner which is big enough to accommodate a full X-ray plate, ( typically 30x40cm),however scanners of this size are more expensive. Smaller good quality scanners can be used, but each plate will have to be scanned in sections and then these sections will have to be mosaiced together, thus increasing your work load. The National Gallery, London, is currently using a Fuji Lanovia Aquire (C-550) A3+ flatbed scanner[#note72\ 9], to scan X-ray plates. Using a good quality digital camera. If an X-ray plate is mounted, above or in front of a large diffuse light source, e.g. a light box, it can be photographed using a digital camera. As can be expected, the quality of your resultant digital images will depend on the quality of your camera and light source. Given a choice between these two methods it is recommended that you use a flatbed scanner, as this will ensure greater uniformity of the scanned images. It is also much easier to ensure that both an x-ray plate and the scanning apparatus are parallel. It should be noted that for small scale or one off projects it might be advisable to have your X-ray plates scanned commercially if you do not have the equipment/resources to carry out the procedure yourself. NB: By taking care that all of your X-ray plates are scanned consistently, i.e. orientation/rotation, you can limit the amount of future image manipulation that may be required. Digital X-rays: Over the last few years it has become possible to bypass the X-ray film altogether and capture digital X-rays. These machines are becoming popular in the medical and dental professions, however it will probably be several years before this technique becomes common in the field of conservation.

Resolution and Image Size:

sec:xray_res When it comes to scanning your X-ray plates you do not necessarily want to scan them at the highest resolution your system can cope with. You have to think about why you are scanning each set of X-ray plates and consider how you are going to store the resultant digital information. X-ray plates can be scanned for several different reasons; to archive your X-ray plates digitally, in order to facilitate further examination of local details, or in preparation for the production of large mosaics. For example when you are planning to create an X-ray mosaic you need to consider the size of the individual digital files you will create, but also the size of the resultant mosaic. nip2 is capable of dealing with images over 1GB, however, unless you have a fast computer processing this sort of image can take a while. In the National Gallery, London, X-ray plates are normally scanned to produce 16-bit, 300DPI, mono tiff images, with a file size of about 40MB. If you are planning to scan a large number of X-ray plates it is good to define your own conventions, depending on what equipment you have and how you plan to store you digital information, for example tt is possible the scan the plates at one resolution for archiveing and then mosaic together smaller versions to produce a useable composite.

16-bit or 8-bit images ??

For black and white images the number of bits in an image refers to the number of different levels of grey the image contains. For example an 8-bit images contains 28 or 256 levels of grey and a 16-bit image can contain 216 or 65536 levels of grey. Processed X-ray plates can contain more than 30000 levels of grey, so if only 8-bit images are produced much of the information stored within the X-ray plate can be averaged out and lost. This often leaves detail in the mid tones but some of the detail in the dark and light areas of an X-ray image can just be lost, leaving plain black or white passages. Therefore, if possible, it is recommended that X-rays be scanned to produce 16-bit images to preserve the density range of the X-ray plate within the digital file. A basic definition of the term bit-depth can be seen in section [#sec:bit_depth 3.3.2]sec:bit_depth.

Mosaicing Digitised X-rays Images.

Once they have been produced digitised X-ray images can then be mosaiced together using the Two tie-point mosaicing functions as described in section [#sec:mosaicing 6.3]sec:mosaicing.

Mask Production

[center|frame|*'A selection of masks defined to balance this mock x-ray image of a canvas painting on a simple four membered stretcher: **A:** The original X-ray image, **B:** The control mask, **C:** Vertical stretcher bars only, **D:** Horizontal stretcher bars only, **E:** Overlap of or join area between the Vertical and Horizontal stretcher bars, **F:** Single thickness of keys only, **G:** Overlap of two keys and **H:** Overlap of keys and stretcher bars.*'](/Image:canvas_masks.jpg "wikilink")

Choosing which masks to produce.

sec:mask_production With nip2 the production of masks[#note73\ 10] is the most time-consuming stage in the balancing of X-rays, as the actual balancing procedure is mostly automatic. Therefore it is good to plan which masks you are going to need. The number of masks required will depend on the complexity of the secondary support. Also the number of masks required will vary depending how well balanced the image needs to be, for example the requirements of an image needed for studio examination may differ from an image needed for publication. A good general rule is to begin with the minimum number of masks and then produce more as required. In an X-ray of a painting the degree of tonal imbalance caused by the secondary support will depend on what it is made of and its thickness. Therefore the basic set of masks required will depend on the number of different materials and thicknesses of the support. Also when sections of the secondary support overlap each other, the X-rays have to pass through a greater thickness. Therefore all of the different areas of overlap, joins, keys, etc., can require separate masks.

Example: A simple four membered stretcher

This support is composed of four stretcher bars and eight keys. The first stage of mask production is to assume that each of the stretcher bars and each of the keys are the same thickness. That would indicate three masks; the control mask, the area covered by the stretcher and then the area covered by the keys. This may be sufficient to produce an acceptable image, but probably not as it does not take into account areas of overlap. Possible additional masks would include overlaps of the stretcher bars and keys. A more complete set of masks could include a total of seven masks:

  • Control Mask: Central area of unobscured canvas.
  • Mask 1: Vertical stretcher bars only.
  • Mask 2: Horizontal stretcher bars only.
  • Mask 3: Overlap of or join area between the Vertical and Horizontal stretcher bars.
  • Mask 4: Single thickness of keys only.
  • Mask 5: Overlap of two keys.
  • Mask 6: Overlap of keys and stretcher bars.

Example: A panel with a simple cradle

In this example the support is composed of two sets of cradle members; one vertical and one horizontal. The first stage of mask production is to assume that all of the cradle members in each set are the same thickness. That would indicate four masks; the control mask, the area covered by vertical cradle members only, the area covered by horizontal cradle members only and the areas where the horizontal and vertical cradle members overlap.

  • Control Mask: Central area of unobscured panel.
  • Mask 1: Vertical cradle members only.
  • Mask 2: Horizontal cradle members only.
  • Mask 3: Overlap of Vertical and Horizontal cradle members.
[center|frame|*'A selection of masks defined to balance this mock x-ray image of a panel painting with a simple cradle: **A:** The original X-ray image, **B:** The control mask, **C:** Vertical cradle members only, **D:** Horizontal cradle members only and **E:** Overlap of Vertical and Horizontal cradle members.*'](/Image:panel_masks.jpg "wikilink")
[center|frame|*'Basic mask production: **A:** The original X-ray image, **B:** Area of interest outlineed in black, **C:** Area of interest flooded with black, **D:** The finished mask image.*'](/Image:mask_production.jpg "wikilink")

Producing Masks

A basic description of how to use the nip2 painting tool functions has been given in section [#sec:paint 5.13]sec:paint, please read it before you continue. Masks can be produced with nip2 as follows[#note74\ 11], see figure [#fg:mask_production 7.3]fg:mask_production:

  • Make a copy of the small version of the image, if your are working with 16-bit x-ray images convert your copy to an 8-bit version using: [Main Window][Toolkits: Image: Levels: Scale to 0 - 255][#note75\ 12]. Save the copy and then open it up in a new column, for example as object B1.
  • In the column command line[#note76\ 13] type in: B1 + 1 and hit [Return][#note77\ 14]
  • Open the resulting image, B2 and open the painting tool bar in the image viewer, see section [#sec:paint 5.13]sec:paint.
  • Select a nib size of 3 round.
  • Use the Draw straight lines tool to carefully outline the area of interest ensuring that the outline is complete with no gaps.
  • Then you can select the Flood while pixel not equal to ink and CLMB in the center of the outlined area to fill it with black. NB: if the whole image goes black then there is a gap in you outline, you will need to CLMB on the Undo last paint action button and then find and fill in the gap in your outline.
  • In the column command line type in: B2 == 0 and hit [Return]
  • Object B3 should now be a black and while image with the area of interest highlighted in white.
  • Object B3 can now be saved onto your computer. It is recommended that you save all masks as png files as they provide a good degree of compression without blurring the edges of your defined areas.

Short Cut in Mask Production: Addition and Subtraction.

Drawing lines around each individual area of interest can take some time so it is good to spend a few minutes thinking about the most efficient way of doing it. The following example will demonstraight one method of possibly speeding up the process. In the simple cradle example given before, see figure [#fg:panel_masks 7.2]fg:panel_masks, each of the masks was composed of a set of little rectangular shapes, drawing round each of those shapes individually can be quite time consuming. A faster way to produce these masks is to start with two easier masks defining the complete horizontal and complete vertical cradle members, see figure [#fg:hor_vert_masks 7.4]fg:hor_vert_masks. Assume both of these masks have been made and have been loaded into a new column as A1 (for the complete horizontal) and A2 (for the complete horizontal). The finished masks can be produced as follows:

[center|frame|'''Two basic masks produced from the example panel x-ray; **A:** Mask definging the horizontal cradle members only and **B:** a mask defineing the vertical cradle members only. '''](/Image:hor_vert_masks.jpg "wikilink")
  • Mask 1: Vertical cradle members only., see image C in figure [#fg:panel_masks 7.2]fg:panel_masks.
  • A3 can be produced with: textbf[column command line] type (A1 - A2) > 0 and hit [Return]
  • Mask 2: Horizontal cradle members only., see image D in figure [#fg:panel_masks 7.2]fg:panel_masks.
  • A4 can be produced with: textbf[column command line] type (A2 - A3) > 0 and hit [Return]
  • Mask 3: Overlap of Vertical and Horizontal cradle members. , see image D in figure [#fg:panel_masks 7.2]fg:panel_masks, is slightly more complicated
  • A5 can be produced with: textbf[column command line] type ((A1 + A2) - (A3 + A4)) > 0 and hit [Return][#note78\ 15]

Manual Balancing: Digital suppression of Stretchers and Cradles in X-ray Images.

sec:man_bal

Stage 1: Find Correction Values

  • In a new column load in the small version of your X-ray, the control mask and the set of normal masks.
  • Select all of the normal masks and group then together: [Main Window][Edit: Group]
  • Open a new column and then in order select the image, the control mask and then the group of mask.
  • Then run the Find functions: [Main Window]:[Toolkits: Tasks: Mosaic: Manual Balance: Find Values]
  • Once the function has finished it will create a special table of numbers, known as a matrix, see figure [#fg:man_bal 7.5]fg:man_bal. This represents the scale and offset values[#note79\ 16] required to balance each mask defined area relative to the area defined by the control mask.

Stage 2: Test Correction Values

  • Select the small version of your image, the matrix produced in stage 1 and the group of masks.
  • Then run the Check functions: [Main Window]:[Toolkits: Tasks: Mosaic: Manual Balance: Check Values]
  • This will produce a complex image object similar to the one shown in figure [#fg:man_bal 7.5]fg:man_bal[#note80\ 17].
    • The blur slider will soften the edges of your masks and can help to improve your image, in most cases it is not required and can be left at zero.
    • The adjust sliders can be used to apply small additional correction to the scale and offset values being applied for each mask.
  • In most cases, if the masks are correct, this new image will be a correctly balanced version of the small version of your original X-ray image. If the images does not appear to be balanced you can apply small corrections using the blur and adjust sliders. If the problems are associated to particular areas of your image you may need to produce additional or different masks and redo stages 1 and 2, for example separate masks may be needed to define each individual stretcher bar, or some cradle members may be slightly thicker than the others.
  • Once the image is correctly balanced check the Build option and then open up the Output object to display the scale and offset correction images.[#note81\ 18]
  • Save[#note82\ 19] the scale_im and offset_im images as vips files to complete stage 2.

Stage 3: Apply Correction Values

  • In a new column load in the full size X-ray image and the scale_im and offset_im images.
  • In order select the full size X-ray, the scale_im and offset_im images.
  • Then run the Apply functions: [Main Window]:[Toolkits:Tasks:Mosaic:Manual Balance:Apply Values]
  • You can then save the full sized balanced X-ray to complete stage 3.
  • The results of the balancing procedure carried out using the two sets of masks listed before can be seen in figure [#fg:man_bal_result 7.6]fg:man_bal_result.
[center|frame|**A `nip2` column displaying the complete results of the first two stages of the manual balancing process.**](/Image:man_bal.jpg "wikilink")
[center|frame|**Both of the mock x-ray images used in this section balance to produce the same simplified image.**](/Image:man_bal_result.jpg "wikilink")

[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19]

References

[1] This process does not create any new information only adjust the appearance of existing information. New x-ray examinations will need to be performed to replace over or underexposed plates.

[2] For example: Producing X-rays after the removal of the secondary structure, or after packing the gaps in the secondary support with wood, saw dust, powdered resin (EVA) or sugar which have a similar X-ray absorptivity to the surrounding secondary structure.

[3] see section [#sec:mask 7.1.1]sec:mask

[4] see section [#sec:mask 7.1.1]sec:mask

[5] If the original plates are scanned to produce 300DPI, 16-bit, mono, tiffs

[6] In the steps given below it is assumed that you are going to be working with a large x-ray image, i.e. one larger than about 2000×2000 pixels. If you are working with smaller x-ray images you can just work with a copy of your x-ray image rather than making smaller versions.

[7] If you have very little or no overlap between X-ray plates the mosaicing procedure becomes a lot harder and also complicates the final balancing stages. If possible it may be quicker and easier to produce a new complete set of X-ray plates rather than trying to worked with a bad existing set. If the plates have been cut to join each other exactly it is still possible to produce a digital composite but the results may not be as satisfactory.

[8] It is often easier to create a version which is half or quarter the size of the original image but the exact size does not really matter.

[9] This particular model is no longer available, but newer versions have been produced toreplace it.

[10] see section [#sec:mask 7.1.1]sec:mask

[11] The instructions given describe the process for producing masks in nip2, however the masks can be produced with other pieces of software, such photoshop if you really want to.

[12] The 16-bit information is not required for mask production and working with an 8-bit version will be faster

[13] ref

[14] This process is going to use black or zero value pixels to define areas of interest, adding 1 to your images ensure that there are no original zero pixels in the image.

[15] In this process the > 0 part of the command deletes all of the negative sections of the images produced by subtracting one image from another.

[16] When a scale and offset is applied to an image, or a section on an image the final images values will be equal to: (original value * scale ) + offset

[17] By default the Output object will be closed, see section [#sec:complexobjects 5.2.3]sec:complexobjects and the Build object will not be selected

[18] The scale and offset images are produced by combing the masks and the values in the matrix. Although they normaly appear to be black the pixel values within the scale and offset images, in the areas defined by each of the masks, are equal to the relative values displayed in the matrix.

[19] see section [#sec:save 5.4]sec:save.

Clone this wiki locally