John W. Campbell
This class stores a list of spots found as the result of searching
a diffraction image. The class has methods for adding/deleting spots and
searching an image for spots to add to the list. The individual spots may
be accessed as JdlSearchImageSpot objects.
Class, constructors and methods:
Class Details
Accessible Fields
Constructors
Manipulate Spots List
Get Spots Data
Sort Spots Data
Find Spots on Image
- Package:
- Jdl.JdlPX;
- Class name:
- JdlSearchImageSpotsList
- Class definition:
- public class JdlSearchImageSpotsList
- Extends:
- Object
- Implements:
- none
- Actions:
- none
No fields with public, package or protected access defined.
Constructors are available to construct a JdlSearchImageSpotsList object
with either a default capacity or a user specified capacity.
Constructors:
Default Constructor
Standard Constructor
This constructs a JdlSearchImageSpotsList object with an initial
capacity for 1000 spots to be incremented in blocks of 1000 spots
as required.
- Constructor Definition:
- public JdlSearchImageSpotsList()
- Parameters List:
- none
This constructs a JdlSearchImageSpotsList object with a user specified
initial capacity and a user specified increment if the list needs
to be expanded.
- Constructor Definition:
- public JdlSearchImageSpotsList (int nr, int inc)
- Parameters List:
- nr
- The initial capacity required (number of spots).
- inc
- The increment in number of spots required each time
the list needs to be expanded.
This section has methods to clear the list, to add/delete/insert
replace spots in the list and to sort the spots list.
Methods:
Clear list - clearList
Add spot - addSpot
Insert spot - insertSpot
Replace spot - replaceSpot
Delete spot - deleteSpot
Delete spots - deleteImageSpots
This method clears the spots list (i.e. removes all entries though
does not decrease its capacity).
- Method Definition:
- public void clearList()
- Parameters List:
- none
This method adds a spot to the end of the list.
- Method Definition:
- public void addSpot (JdlSearchImageSpot spot)
- Parameters List:
- spot
- The spot to be added.
This method inserts a reflection at a given position within the list.
- Method Definition:
- public void insertSpot (JdlSearchImageSpot spot, int ispot)
- Parameters List:
- spot
- The spot to be inserted.
- ispot
- The position within the list where the spot is to
be inserted (spot positions numbered from 1 upwards).
This method replaces a spot at a given position within the list.
- Method Definition:
- public void replaceSpot (JdlSearchImageSpot spot, int ispot)
- Parameters List:
- spot
- The spot to replace a current spot.
- ispot
- The position within the list where the spot is to
be replaced (spot positions numbered from 1 upwards).
This method deletes a spot from the list.
- Method Definition:
- public void deleteSpot (int ispot)
- Parameters List:
- ispot
- The position within the list of the spot to
be deleted (spot positions numbered from 1 upwards).
This method deletes spots for a given image number from the list.
- Method Definition:
- public void deleteImageSpots (int img_id)
- Parameters List:
- img_if
- The image identifier of the spots to be deleted.
This section has methods to retrieve data from the spots list.
Methods:
Get number of spots - getNumberOfSpots
Get spot reference - getSpot
Get spot copy - getSpotCopy
This method returns the number of spots currently in the spots list.
- Method Definition:
- public int getNumberOfSpots()
- Parameters List:
- none
- Method Return:
-
The number of spots in the list.
This method returns a reference to the store JdlSearchImageSpot
object for a spot at a selected position in the list.
- Method Definition:
- public JdlSearchImageSpot getSpot (int ispot)
- Parameters List:
- ispot
- The position in the list of the spot to be returned (from
1 upwards).
- Method Return:
-
The JdlSearchImageSpot object for the spot (reference
to stored object - not a copy/clone).
This method returns a copy of the JdlSearchImageSpot
object for a spot at a selected position in the list.
- Method Definition:
- public JdlSearchImageSpot getSpotCopy (int ispot)
- Parameters List:
- ispot
- The position in the list of the spot to be returned (from
1 upwards).
- Method Return:
-
A JdlSearchImageSpot object for the spot. This is
a clone (copy) of the stored object.
This section has a method to sort the spots list.
Method:
Sort spot list - sortSpotsList
This method sorts the spot list by local axis 1 coordinate, local axis 2
coordinate or intensity.
- Method Definition:
- public void sortSpotsList(int order)
- Parameters List:
- order
- Sort order:
= 1, Sort on local axis 1 coordinate
= 2, Sort on loacl axis 2 coordinate
= 3, Sort on intensity
This section has methods to search an image and add the found spots to
the spots list. Some statistics are returned in a SpotStats Object
(JdlSearchImageSpotsList.Spotstats) with the following public fields:
public int nspots; // Number of spots found
public double siz_ax1; // Average spot size along first local axis
public double siz_ax2; // Average spot size along second local axis
public double ave_int; // Average intensity
public double max_int; // Maximum intensity
public int nbad; // Total number of bad spots
public int n_box_big; // Too big from box search
public int n_ell_big; // Too big from elliptical search
public int n_shifted; // Too big a shift on re-processing
The last four items are only set if the reprocessSpotList(..) method is used.
Methods:
Find spots on image - findSpots
Find spots on image - findSpots
Find spots on image - findSpots
Find spots on image - findSpots
Re-process spots list - reprocessSpotList
Average spot separation - averageSpotSeparation
This method searches a diffraction image for spots. Tn this version of
the method, most of the required parameters are passed via a
JdlDiffractionDataModule object or given default values. For a further
description of the method, see the final version of the method below.
(The default values used are threshfac=10.0, minpix=2, rexcl=2.0,
x_split=0.0, y_split=0.0)
- Method Definition:
- public SpotStats findSpots(JdlImageData imgd, JdlDiffractionDataModule ddm, int iset, int imgnum, int irange, boolean add_tolist, JdlProgressHandler progress, JdlError jerr)
- Parameters List:
- imgd
- JdlImageData object holding details of the image and a
pre-calculated background image.
- ddm
- A JdlDiffractionDataModule object (with rmax, x_cen, y_cen,
x_min, x_max, y_min, y_max, rmin, r_xcen, r_ycen).
- iset
- The set number (>0).
- imgnum
- The image number within the range (>0).
- irange
- The rotation range number.
- add_tolist
- If true, add the found spots to any currently in the
spots list; if false, clear the spots list before adding the found spots.
- progress
- Progress handler (may be null if not required)
- Method Return:
-
A spot statistics object (see section description for details)
This method searches a diffraction image for spots. In this version of
the method, some of the required parameters are passed via a
JdlDiffractionDataModule object rather than explicitly. For a further
description of the method, see the final version of the method below.
- Method Definition:
- public SpotStats findSpots(JdlImageData imgd, JdlDiffractionDataModule ddm, int iset, int imgnum, int irange, double threshfac, int minpix, double rexcl, double x_split, double y_split, boolean add_tolist, JdlProgressHandler progress, JdlError jerr)
- Parameters List:
- imgd
- JdlImageData object holding details of the image and a
pre-calculated background image.
- ddm
- A JdlDiffractionDataModule object (with rmax, x_cen, y_cen,
x_min, x_max, y_min, y_max, rmin, r_xcen, r_ycen and phi mid-point).
- iset
- The set number (>0).
- imgnum
- The image number within the range (>0).
- irange
- The rotation range number.
- threshfac
- The method considers pixels more than
threshfac*sqrt(background) above local background as being pixels
which belong to spots.
- minpix
- The minimum number of pixels to consider as a spot.
- rexcl
- The method uses rmin+rexcl and rmax-rexcl as the
actual limits for the minimum and maximum radii to avoid edge of detector
problems with the spot search calculation. 'rexcl' is given in mm.
The method also uses applies the same exclusion round the edge of the
detector (or the x_min, x_max, y_min, y_max limits).
- x_split
- Spots less than x_split mm apart along 'x' are considered
as one spot.
- y_split
- Spots less than y_split mm apart along 'y' are considered
as one spot.
- add_tolist
- If true, add the found spots to any currently in the
spots list; if false, clear the spots list before adding the found spots.
- progress
- Progress handler (may be null if not required)
- Method Return:
-
A spot statistics object (see section description for details)
This method searches a diffraction image for spots. Tn this version of
the method, some of the required parameters are passed via
JdlPositionedDetector and JdlDetectorLimits objects rather than
explicitly. For a further description of the method, see the final version
of the method below.
- Method Definition:
- public SpotStats findSpots(JdlImageData imgd, int img_id, double phimid, JdlPositionedDetector posdet, JdlDetectorLimits lim, double x_cen, double y_cen, double threshfac, int minpix, double rexcl, double x_split, double y_split, boolean add_tolist, JdlProgressHandler progress)
- Parameters List:
- imgd
- JdlImageData object holding details of the image and a
pre-calculated background image.
- img_id
- Image identifier or number (>0) - create from image number
(>0) and rotation range number using the static method
JdlDiffractionDataModule.setImageID(..).
- phimid
- The rotation angle (mid point) in degrees for the image.
May be 0.0 if the list of spots is to be used for positions only and not,
for example, for determining a crystal setting.
- posdet
- A JdlPositionedDetector object (with rmax).
- lim
- A JdlDetectorLimits object (x_min, x_max, y_min, y_max, rmin,
r_xcen, r_ycen).
- x_cen
- Centre of pattern image along the first local axis in rasters.
- y_cen
- Centre of pattern image along the second local axis in rasters.
- threshfac
- The method considers pixels more than
threshfac*sqrt(background) above local background as being pixels
which belong to spots.
- minpix
- The minimum number of pixels to consider as a spot.
- rexcl
- The method uses rmin+rexcl and rmax-rexcl as the
actual limits for the minimum and maximum radii to avoid edge of detector
problems with the spot search calculation. 'rexcl' is given in mm.
The method also uses applies the same exclusion round the edge of the
detector (or the x_min, x_max, y_min, y_max limits).
- x_split
- Spots less than x_split mm apart along 'x' are considered
as one spot.
- y_split
- Spots less than y_split mm apart along 'y' are considered
as one spot.
- add_tolist
- If true, add the found spots to any currently in the
spots list; if false, clear the spots list before adding the found spots.
- progress
- Progress handler (may be null if not required)
- Method Return:
-
A spot statistics object (see section description for details)
This method searches a diffraction image for spots. As well pre-calculated
background image is passed to the method and the method searches for pixels
at a certain threshold above background to determine those pixels which are
presumed to belong to spots. The method continuously updates the spot position
by updating the calculation of its centre of gravity as the spot is
built up from contiguous above threshold pixels. In this version of
the method, only the image data are passed using a special object; all
other control parameters have their values given explicitly.
- Method Definition:
- public SpotStats findSpots(JdlImageData imgd, int img_id, double phimid, double rmax, double x_cen, double y_cen, double x_min, double x_max, double y_min, double y_max, double rmin, double r_xcen, double r_ycen, double threshfac, int minpix, double rexcl, double x_split, double y_split, boolean add_tolist, JdlProgressHandler progress)
- Parameters List:
- imgd
- JdlImageData object holding details of the image and a
pre-calculated background image.
- img_id
- Image identifier or number (>0) - create from image number
(>0) and rotation range number using the static method
JdlDiffractionDataModule.setImageID(..).
- phimid
- The rotation angle (mid point) in degrees for the image.
May be 0.0 if the list of spots is to be used for positions only and not,
for example, for determining a crystal setting.
- rmax
- Maximum radius of active area in mm.
- x_cen
- Centre of pattern image along the first local axis in rasters.
- y_cen
- Centre of pattern image along the second local axis in rasters.
- x_min
- Low limit in rasters on 1'st local axis of area to include
(0.0=image minimum).
- x_max
- High limit in rasters on 1'st local axis of area to include
(0.0=image maximum).
- y_min
- Low limit in rasters on 2'nd local axis of area to include
(0.0=image minimum).
- y_max
- High limit in rasters on on 2'nd local axis of area to include
(0.0=image maximum).
- rmin
- Minimum radius of active area in mm.
- r_xcen
- Centre of pattern image along the first local axis in rasters
for rmin calculation (Use x_cen if r_xcen=0.0 & y_cen=0.0).
- r_ycen
- Centre of pattern image along the second local axis in rasters
for rmin calculation (Use y_cen if r_xcen=0.0 & y_cen=0.0).
- threshfac
- The method considers pixels more than
threshfac*sqrt(background) above local background as being pixels
which belong to spots.
- minpix
- The minimum number of pixels to consider as a spot.
- rexcl
- The method uses rmin+rexcl and rmax-rexcl as the
actual limits for the minimum and maximum radii to avoid edge of detector
problems with the spot search calculation. 'rexcl' is given in mm.
The method also uses applies the same exclusion round the edge of the
detector (or the x_min, x_max, y_min, y_max limits).
- x_split
- Spots less than x_split mm apart along 'x' are considered
as one spot.
- y_split
- Spots less than y_split mm apart along 'y' are considered
as one spot.
- add_tolist
- If true, add the found spots to any currently in the
spots list; if false, clear the spots list before adding the found spots.
- progress
- Progress handler (may be null if not required)
- Method Return:
-
A spot statistics object (see section description for details)
This method re-processes the spots list. The method searches around
each spot position in the stored spots list (using a box 'box_fac' times the
spot size based on the spot sizes found for the 25% of spots between positions
70% and 95% in the spots list sorted by intensity) and finds better spot
positions and sizes, normally using lower thresholds than in the original
search. For any large spots (more than twice the average size in either
dimension found as described) a surrounding box is examined using
a threshold of 25% of the maximum pixel intensity in that box to see if it
may contain multiple spots; if so these will be separated and added
to the spots list provided that they are not already there (spot within
0.3 of a spot dimension in each direction). If any of these spots are
still more than twice the average size in either dimension, they are
flagged as bad spots (spot_flag = 2). All other spots are then examined
by taking taking a box of data around the spot ('box_fac' times the average
spot size) and centering an ellipse (axial ratio based on average spot sizes)
and expanding/contracting it to find the size where 'pcnt' of the pixels are
above a threshold of 'thr' standard deviations above the background. A new
centre of gravity is then determined based on the pixels within this
ellipse. The process is iterated ('niter' iterations). If the ellipse
expands to the box limit without sufficient below threshold pixels found
the the spot is flagged as a bad spot (spot_flag = 3). If the new centre of
gravity determined is too far from the original spot position (more than
0.33 of the average spot dimension in either direction), then the spot is
flagged as a bad spot (spot_flag = 4).
- Method Definition:
- public SpotStats reprocessSpotList(JdlImageData imgd, double box_fac, double pcnt, double thr, int niter, double step, JdlProgressHandler progress)
- Parameters List:
- imgd
- JdlImageData object holding details of the image and a
pre-calculated background image.
- box_fac
- Box size factor >= 2.0 (e.g.3.0). The box size will be set to
the nearest size in pixels based on this factor and the spot size as described
above and then incremented by one, if necessary, to make it an odd number.
- pcnt
- Percentage of pixels which must be above threshold as
determined by 'thr' (e.g.90.0).
- thr
- Pixel values at least this number of standard deviations above the
background will be used to determine the dimensions of the spot which
is taken as an elliptical shape around the spot centre of gravity for
which 'pcnt' percent of the pixels are above this threshold level (e.g. 3.0).
- niter
- Number of iterations of spot centre of gravity and spot
size determination (e.g. 2).
- step
- Step size in pixels used in determining the spot size
parameters (0.1 to 1.0) (e.g. 0.25).
- progress
- Progress handler (may be null if not required).
- Method Return:
-
A spot statistics object (see section description for details)
Find the average spot separation from the nearest neighbour spot (in rasters).
Note: This method sorts the spot list on the first axis.
- Method Definition:
- public double averageSpotSeparation(double pixr)
- Parameters List:
- pixr
- Ratio of pixel size along second local axis divided by that
along first local axis. (pixsix_ax2/pixsiz_ax1).
- Method Return:
-
Returns the average spot separation in local axis 1 rasters.
⇑ Up 2
⇑ Up 1
⇑ Top of this