User's guide
Table of content
1- black
2- color_to_bw
3- ctrst
4- defect
5- enh_pro
6- grid_sm
7- kernel
8- Logsig
9- low_bit
10- mat_fl_to_uc
11- matresul
12- median_filter
13- mod_ther
14- moment
15- Planck
16- plot_img
17- poin_pro
18- profil
19- read_fl
20- read_uc
21- smooth
22- snr
23- stretch
24- timezones
25- write_uc
1
***black***
- Description
The purpose of this function is to change the color map of Matlab to a black color map
with 'num' levels of black values and return the new 'out' color map matrix. This function is
usefull to get all black 3D plots. To restore original color map, use one of these commands:
colormap(gray); or colormap(jet); for more information use: help colormap.
- Syntax
out = black(num)
- Input parameter
num: number of levels of black values.
- Output parameter
out: new 'num' x 3, all zeros, color map matrix.
- Example of use
black(64);
(for 64 levels of black)
- Links with other functions
This function is used by 'matresul'.
2
***color_to_bw***
- Description
Routine to convert a color image into a black and white one based on a color scale
included in the image and located in the rectangle with upper left corner x1,y1 and bottom right
corner x2,y2. x is the row coordinate and y is the column coordinate. If x1, y1, x2 and y2 are
not provided, the function will ask the user to click on the upper left and bottom right corners
of the scale with the mouse. Provided are the three splitted channels on 8 bits: red (matr),
green (matg) and blue (matb). Returned matrix 'mat' is the black and white image coded on
unsigned char (0 to 255).
This routine is useful to convert color scanned printed thermograms whose black and
white version is not available. Splitted channel images are easily obtained from the original
image in software such as Paint Shop Pro among others.
- Syntax
mat = color_to_bw(matr, matg, matb, varargin)
- Input parameters
matr: red channel.
matg: green channel.
matb: blue channel.
varargin: x1,y1,x2,y2, optional.
- Output parameter
mat: black and white image.
- Adjustable parameter
Number: number of elements taken on each side to average the scale. If you want the scale to remain unchanged, set Number to 0 (default value: 2).
- Examples of use
image_bw=color_to_bw(matr, matg, matb);
image_bw=color_to_bw(matr, matg, matb, 60, 10, 65, 100);
(where matr, matg and matb are the three splitted rgb channels)
- Links with other functions
This function uses 'mat_fl_to_uc'.
3
***ctrst***
- Description
This function is used to compute the thermal contrast of an image. Many definitions are
used to compute this thermal contrast. The 'TYPE' parameter enables the user to choose between:
1- the absolute contrast (equation 5.32), 2- the running contrast (equation 5.33), 3- the
normalized contrast (equation 5.34) and 4- the standard contrast (equation 5.35). 'mat' is the
image at time t and 'mat0' is the image at time tm for the normalized contrast and the image at
time t0 for the standard contrast. The defect-free reference region is defined by x1,y1 for the
upper left corner and by x2,y2 for the bottom right corner.
- Syntax
mat1 = ctrst(TYPE,x1,y1,x2,y2,mat,mat0)
- Input parameters
TYPE: choose which contrast to compute: 1-absolute contrast, 2-running contrast,
3-normalized contrast and 4-standard contrast.
x1: row coordinate of the upper left corner of the defect-free zone.
y1: column coordinate of the upper left corner of the defect-free zone.
x2: row coordinate of the bottom right corner of the defect-free zone.
y2: column coordinate of the bottom right corner of the defect-free zone.
mat: thermal image at time t for which the contrast is being computed.
mat0: image at time tm for TYPE 3 and at time t0 for TYPE 4. This parameter is not
used for TYPE 1 and 2, and can be anything in those cases.
- Output parameter
mat1: contrast image.
- Examples of use
mat_ctr=ctrst(1,2,2,50,10,image);
mat_cts=ctrst(3,2,2,50,10,image,imagem);
- Theory and equations
Chap 5, section: Thermal contrast computations
equations 5.32, 5.33, 5.34 and 5.35
4
***defect***
- Description
Implementation of the automatic defect detection procedure on unsigned char image 'mat'
with parameter 'MND'. If parameter 'cross' is set to 1, returned image 'mat1' is equal to 'mat'
with only crosses indicated at defect center. Any other value of 'cross' returns 'mat1' as a map
of defect(s) detected in 'mat' (0 value at background and 1 value at defect location).
Note: if you have the 'Image Processing Toolbox', you may add a parameter (any number
will do) after 'cross' to enable the use of functions from this toolbox. You may obtain better
results with these functions.
- Syntax
[mat1, varargout] = defect(mat,MND,Max_def,cross,varargin)
- Input parameters
mat: image that is searched for defects.
MND: minimum distance value between defect centers in pixels.
Max_def: maximum number of defects that can be found in an image.
cross: 1 if you want the image returned to be 'mat' with crosses indicating defect
centers, else if you want the image returned to be a map of defects detected in
mat.
varargin: parameter that enables the use of the 'Image Processing Toolbox'. If
empty, the function 'median_filter' will be used instead.
- Output parameters
mat1: image that is returned, depends on the parameter 'cross'.
varargout: matrix containing: first column: row of defect center, second column:
column of defect center and third column: value of defect center.
- Adjustable parameters
Border_width: width in pixels of the border around the image that is not searched for
defects. Minimum value is 1 pixel to have enough space for crosses
(default value: 4).
Cross_size: width on each side of the cross in pixels. 'Cross_size' must be smaller
or equal to 'Border_width', if 0 only a point appears at defect centers
(default value: 2).
Alpha: used to find the minimum value of a defect. The equation is:
min=Alpha*(mean_value+Alpha*std_dev) where 'mean_value' is the mean value of
'mat' and 'std_dev' is the standard deviation of 'mat'. If the value of 'Alpha'
is too high, no defect will be found (default value: 1.0).
- Examples of use
image_alone=defect(image,50,10,0);
[image_cro, out]=defect(image,50,10,1);
[image_def, out]=defect(image,50,10,0);
[image_IPT, out]=defect(image,50,10,0,1);
- Theory and equations
Chap 6, section: Automatic segmentation algorithm
equation 6.11, 6.12, 6.13, 6.14, 6.15, 6.16 and 6.17
- Links with other functions
This function uses 'median_filter' or the 'Image Processing Toolbox' if available.
5
***enh_pro***
- Description
Function for image enhancement with parameters 'k1' and 'k2'. It returns the enhanced
image, based on equation 5.20. To obtain equation 5.19, set 'k2' to 1. In this case, here are
the effects obtained depending on 'k1': k1=1, there is no effect; 0<=k1<=1, a smoothing effect
is obtained; k1>1, the image is sharpened through an increase of frequencies, as with an
high-pass filter.
- Syntax
mat1 = enh_pro(mat,k1,k2)
- Input parameters
mat: image that is being enhanced.
k1: gain factor, parameter from equations 5.19 and 5.20.
k2: parameter from equation 5.20, if k2=1, equation 5.19 is obtained.
- Output parameter
mat1: enhanced image.
- Adjustable parameter
Size: for each pixel, the local mean is calculated over a 'Size' pixels wide window
(default value: 3).
- Example of use
image_enh=enh_pro(image,5,0.5);
- Theory and equations
Chap5, section: Image rectification, Detail enhancement of thermographs using local
statistics
equations 5.19 and 5.20
6
***grid_sm***
- Description
This function is used to reduce the grid size of an image 'mat' by blocks of size
'block'.
- Syntax
out = grid_sm(mat,block)
- Input parameters
mat: image that is being sampled.
block: size of the blocks of the grid.
- Output parameter
out: image which was sampled by blocks of size 'block'.
- Example of use
imagesm=grid_sm(image,4);
- Theory
Chap 5, section: Image fundamentals
7
***kernel***
- Description
Function for image enhancement through the use of a kernel of values. This kernel is a
square the same size as 'array' centered on the processed pixel. The central pixel is replaced
by the sum of the pixels forming the kernel of interest, pondered by 'array' and multiplied by
the scaling factor 'ascale'.
- Syntax
mat1 = kernel(mat,ascale,array)
- Input parameters
mat: image that is being enhanced.
ascale: scaling factor.
array: kernel of values.
- Output parameter
mat1: enhanced image.
- Example of use
image_ker=kernel(image,1/9,smo);
(where 'smo'is the smoothing operator, smo=ones(3);)
- Theory and equation
Chap 5, section: Image rectification, Spatial domain image enhancement
equation 5.16
8
***Logsig***
- Description
This function displays the logsig neural network activation function (f=1/(1+e^(-n))) in
black color.
- Syntax
Logsig
- Example of use
Logsig;
- Theory and equation
Chap 6, section: Neural network detection, Neural network fundamentals
equation 6.22
9
***low_bit***
- Description
This fucntion reduces the number of bit per pixel of an image 'mat' by value 'ratio'.
The new number of bit per pixel can be calculated as follow:
new_number_of_bit=log(256/ratio)/log(2).
- Syntax
out = low_bit(mat,ratio)
- Input parameters
mat: image for which the number of bit per pixel is being reduced.
ratio: the value by which the number of bit per pixel is reduced.
- Output parameter
out: image whith reduced bit per pixel.
- Example of use
imagelow=low_bit(image,8);
(the number of bit per pixel is reduced to 5, log(256/8)/log(2) = 5)
- Theory
Chap 5, section: Image fundamentals
10
***mat_fl_to_uc***
- Description
The purpose of this function is to convert a floating point (4 bytes per pixel) matrix
'mat' to an unsigned char matrix 'out' (1 byte per pixel). If this function is used with an
image that is already of unsigned char type, it has for effect to span the values of the image
from 'N_BAS' to 'N_HAUT'.
- Syntax
out = mat_fl_to_uc(mat)
- Input parameter
mat: matrix of float type data (32 bits per pixel).
- Output parameter
out: matrix of unsigned char type data (8 bits per pixel).
- Adjustable parameters
N_HAUT: maximum value in returned image (default value: 255).
N_BAS: minimum value in returned image (default value: 0).
- Example of use
image_uc=mat_fl_to_uc(image);
- Theory
Chap 5, section: Image fundamentals
- Links with other functions
This function is used by 'color_to_bw' and 'moment'.
11
***matresul***
- Description
This function extracts relevant time zones ('l1' to 'l2') data from the image 'mat'.
Returned matrix is formed by the columns 'l1' to 'l2' from image 'mat'. A 3D plot is provided
with black color map.
- Syntax
out = matresul(mat,l1,l2)
- Input parameters
mat: image from which the data is extracted.
l1: first column from where the data is relevant.
l2: last column up to where the data is relevant.
- Output parameter
out: image composed of columns 'l1' to 'l2' of the matrix 'mat'.
- Example of use
imageresul=matresul(image,25,37);
- Links with other functions
This function uses 'black'.
12
***median_filter***
- Description
This function is used for noise suppression through median filtering. Parameter 'size'
defines the size of the kernel of interest and must be a odd number. The kernel is a 'size' x
'size' square centered on the processed pixel. The central pixel is replaced by the median value
of the pixels forming the kernel of interest.
- Syntax
mat1 = median_filter(mat,size)
- Input parameters
mat: image that is being filtered.
size: size of the kernel of interest (if 'size' is even, the function uses 'size' +1).
- Output parameter
mat1: processed image.
- Example of use
imagemed=median_filter(image,3);
- Theory
Chap 5, section: Image rectification, Spatial domain image enhancement
- Links with other functions
This function is used by 'defect'.
13
***mod_ther***
- Description
Heat transfer modeling. The default result is the distribution computed for a graphite
epoxy speciment.
- Syntax
mod_ther
- Adjustable parameters
Geometry
def_nod_pos: position of defect nodes (default value: 12).
rad_nodes: number of nodes along the radial length (default value: 20).
axe_nodes: number of nodes in depth (default value: 30).
dr: radial width, cm (default value: 0.2).
dz: axial depth, cm (default value: 0.02).
frad: empirical factor which depends of the geometry, w/cm^2 (default value:
5.67e-12).
fcon: empirical factor which depends of the geometry, w*cm^2 (default value:
1.0e-3).
Time and energy pulse
dt: small time increments, seconds (default value: 0.025).
num_it: number of iterations, 30sec / dt (default value: 1200).
source_power: quantity of energy deposited on the front surface, w/cm^2
(default value: 1).
heat_duration: time interval after which source_power=0, seconds (default
value: 2).
Thermal parameters
rhd: density / 1000, Kg/1000*m^3 (default value: 2).
cp: specific heat / 1000, j/Kg*C*1000 (default value: 1).
ra_conduct: radial thermal conductivity (default value: 0.05).
ax_conduct: axial thermal conductivity (default value: 0.01).
kint: axial thermal conductivity for def_nod_pos, default: air (default value:
kint(1:5)=0.00024, kint(6:rad_nodes)=0.01).
ta: ambient temperature, Kelvin degrees (default value: 273).
itemp: initial temperature, Celcius degrees (default value: 0.00001).
- Example of use
mod_ther
- Theory and equations
Chap3, section: Finite difference modeling
equations 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11 and 3.12
14
***moment***
- Description
This function returns the moment image from the image sequence present on disk in
directory 'dir'. Computation proceeds in the time period 'ta' to 'tb' (coded in the name of the
file having the prefix 'pre' and extension 'ext'). 'incre' is the time increment between images.
Possible options are: 1-add all images, 2-average of all images, 3-add all images and convert to
unsigned char.
- Syntax
mat = moment(dir,pre,ext,ta,tb,incre,option)
- Input parameters
dir: directory where the image sequence is present.
pre: prefix of the name of the files.
ext: extension of the name of the files.
ta: beginning of the time period.
tb: end of the time period.
incre: time increment between images.
option: 1-add all images, 2-average of all images, 3-add all images and convert to
unsigned char.
- Output parameter
mat: moment image.
- Adjustable parameters
Header: number of bytes before the image (default value: 105).
MaxRow: number of pixels per row (default value: 68).
Maxcol: number of pixels per column (default value: 105).
- Example of use
moment_image=moment('C:\images\','D_','uc',200,2000,10,2);
- Theory and equation
Chap 6, section: Image formation
equation 6.3
- Links with other functions
This function uses 'mat_fl_to_uc'.
15
***Planck***
- Description
Script that displays Planck's law. No parameter to be specified.
- Syntax
Planck
- Example of use
Planck;
16
***plot_img***
- Description
The purpose of this function is to display a 3D plot of an image 'mat'. The 3D rotation
of the image is enabled. If your want the plot to be in black color, use the function 'black'.
- Syntax
out = plot_img(mat)
- Input parameter
mat: image for which the 3d plot is displayed.
- Output parameter
out: handle to a SURFACE object.
- Example of use
plot_img(image);
17
***poin_pro***
- Description
Point processing routine with parameters 'a' and 'b'. It returns the processed image,
based on figure 5.18. For binarization, set parameter 'b' to 'Maxcolor'. For all other values of
'b', a contrast stretching is obtained. If 'a' and 'b' are set to the same value, the image is
kept unchanged.
- Syntax
mat1 = poin_pro(mat,a,b)
- Input parameters
mat: the image that is being processed.
a: a value in the gray level function (with b=Maxcolor, 'a' becomes the threshold).
b: the new gray level value attributed to the gray level 'a'.
- Output parameter
mat1: processed image.
- Adjustable parameter
Maxcolor: maximum value of a pixel (default value: 255, if on 8 bits).
- Examples of use
imageprolow=poin_pro(image,125,25); (low values emphasized)
imageprohigh=poin_pro(image,125,225); (high values emphasized)
imageprothres=poin_pro(image,80,255);
- Theory and equation
Chap 5, section: Image rectification, Spatial domain image enhancement
equation 5.15
figure 5.18
18
***profil***
- Description
The purpose of this function is to plot a profile from a matrix. After calling the
function, 'mat' is displayed with superimposition of the value 'value' over of the row of
interest 'nrow'. Then, to plot the profile 'out', type the command: plot(out);
- Syntax
out = profil(mat,nrow,value)
- Input parameters
mat: image that contains the row of interest.
nrow: row to be plotted.
value: value to be displayed for the line being plotted.
- Output parameter
out: profile that can be plotted.
- Example of use
prof=profil(image,25,255);
plot(prof);
- Theory
Chap 5, section: Manual interpretation (color scales, profiles), Profiles
19
***read_fl***
- Description
The purpose of this function is to read files of 'float' type of data (4 bytes per
pixel): 'float32', floating-point on 32 bits. A header is accounted for, if any.
- Syntax
out = read_fl(file)
- Input parameters
file: complete directory and name of the image file that is being read.
- Output parameter
out: matrix of the image that was read.
- Adjustable parameters
Header: number of bytes before the image (default value: 0).
MaxRow: number of pixels per row (default value: 68).
Maxcol: number of pixels per column (default value: 105).
- Example of use
image=read_uc('D_4439.uc');
(if D_4439.uc is in the current directory)
- Theory
Chap 5, section: Image fundamentals
20
***read_uc***
- Description
The purpose of this function is to read 'raw' type of files of unsigned char. A header
is accounted for.
- Syntax
out = read_uc(file)
- Input parameters
file: complete directory and name of the image file that is being read.
- Output parameter
out: matrix of the image that was read.
- Adjustable parameters
Header: number of bytes before the image (default value: 105).
MaxRow: number of pixels per row (default value: 68).
Maxcol: number of pixels per column (default value: 105).
- Example of use
image=read_uc('D_4439.uc');
(if D_4439.uc is in the current directory)
- Theory
Chap 5, section: Image fundamentals
21
***smooth***
- Description
This function is used to smooth out noise from image 'mat' employing a sliding Gaussian
window with parameter 'B' (for Gaussian curve's width).
- Syntax
mat1 = smooth(mat,B)
- Input parameters
mat: image that is being smoothed.
B: typically 5 for a 512 x 512 image, 4 for a 100 x 100 image and 2 for a 70 x 70 image.
- Output parameter
mat1: smoothed image.
- Adjustable parameter
Nbpasse: number of iterations for smoothing (default value: 2).
- Example of use
smoothed_image=smooth(image,4);
- Theory and equations
Chap 5, section: Image rectification, Alternative smoothing routine for noise processing
equations 5.29, 5.30 and 5.31
22
***snr***
- Description
Routine to compute the signal to noise ratio between two images, 'mat1' and 'mat2',
recorded one after another. This is usefull for noise evaluation.
- Syntax
snr(mat1,mat2)
- Input parameters
mat1: matrix of the first image.
mat2: matrix of the second image.
- Example of use
snr(image1,image2)
(where image1 and image2 are two images recorded one after the other)
- Theory and equations
Chap 5, section: Image degradation, Noise evaluation
equation 5.13
23
***stretch***
- Description
This function is for histogram stretching through linear remapping of gray level of
image 'mat' within all available gray level range 'gmin' to 'gmax'. In the case of a
low-contrast image, the result obtained is a better visualization of information lost in a too
narrow span of gray levels.
- Syntax
mat1 = stretch(mat,gmin,gmax)
- Input parameters
mat: image that is being stretched.
gmin: minimum gray level value.
gmax: maximum gray level value.
- Output parameter
mat1: stretched image.
- Example of use
imagestr=stretch(image,0,255);
- Theory and equation
Chap 5, section: Image rectification, Spatial domain image enhancement
equation 5.17
24
***timezones***
- Description
This function is used to compute a logarithmic time scale.
- Syntax
out = timezones(NM,q,N,to,tf,p)
- Input parameters
NM: maximum number of images.
q: image acquisition + temporary storage rate.
N: number of zones wanted.
to: starting of acquisition.
tf: end of the experiment.
p: specifies for which case the time zones are computed: 1 for disjoint case and
any other value for continuous case.
- Output parameter
out: logarithmic time scale, first column: number of the zone, second column:
beginning of the time zone and third column: end of the time zone.
- Example of use
time_scale=timezones(284,0.27,10,1,100,1);
- Theory and equations
Chap 10, section: Pulsed thermography: Experimental Procedure for Data Analysis,
Logarithmic time scale: disjoint case, and Logarithmic time scale: continuous case
equations 10.33, 10.34, 10.35, 10.36, 10.42, 10.46, 10.47 and 10.48
25
***write_uc***
- Description
The purpose of this function is to write a 'raw' type of file of unsigned char. No
header is accounted for, 'Header' is filled with blank spaces.
- Syntax
out = write_uc(file,mat)
- Input parameters
file: complete directory and name of the image file that is being saved.
mat: image that is being saved.
- Output parameter
out: number of bytes saved.
- Adjustable parameter
Headersize: number of bytes before the image (default value: 105).
- Example of use
count=write_uc('image.uc',image);
(the file image.uc is written in the current directory)
- Theory
Chap 5, section: Image fundamentals