Name
im_diff - Calculate scaled density difference between two images.
Usage
imdiff, A, B = im_diff(image1,image2,[optional: mask, or radius of a circular mask])
or use a tuple to hold the returned values.
S =im_diff(image1,image2,[optional: mask or radius of a circular mask])
- S[0] = imdiff
- S[1] = A
- S[2] = B
Input
- image1
- The first input image for calculating density difference. It can be either a read-in-core EMData object or a string of file in disk.The image dimension can be 1,2, or 3.
- image2
- The second input image for calculating density difference. It can be either a read-in-core EMData object or a string of file name in disk. The image dimension can be 1, 2 or 3.
- mask
- Mask file, the output density difference image will be calculated under this mask. It can be string of file name in the desk, read-in-core EMData object, integer or float number denoting radius of the circular mask.
- Note: The mask should be of the same dimensions as the input image.
- The default mask is a circle, or sphere, with the radius of min(nx/2-1, ny/2-1, nz/2-1)
Output
- imdiff
- image of the density difference between image1 and image2.
- A
- The linear error scale.
- B
- The average of total error between image1 and image2.
Description
`A = (N*sumP_1*P_2 -sumP_1*sumP_2 )/(N*sum(P_1)^2 -( sumP_1 )^2`
`P_1` and `P_2` are pixel values in image1 and image2, respectively.
- Summation is over all the pixels under the given mask. N is the total number of pixels under mask.
`B = (A*sumP_1 -sumP_2)/N`
`"""imdiff""" = A*P_1-B -P_2`
- When two images are identical, A = 1, B = 0.
- Swapping image1 and image2 will give different A, B, and imdiff.
Author / Maintainer
Bharath K Narayanan/Zhong Huang
Keywords
- category 1
- UTILITIES
- category 2
- SPATIAL
Files
- statistics.py
Maturity
- stable
- works for most people, has been tested; test cases/examples available.
Bugs
None. It is perfect.