Main Content

Calculate weights for image pixels based on grayscale intensity difference

computes
the pixel weight for each pixel in the grayscale image `W`

= graydiffweight(`I`

,`refGrayVal`

)`I`

.
The weight is the absolute value of the difference between the intensity
of the pixel and the reference grayscale intensity specified by the
scalar `refGrayVal`

. Pick a reference grayscale
intensity value that is representative of the object you want to segment.
The weights are returned in the array `W`

, which
is the same size as input image `I`

.

The weight of a pixel is inversely related to the absolute value
of the grayscale intensity difference at the pixel location. If the
difference is small (intensity value close to `refGrayVal`

),
the weight value is large. If the difference is large (intensity value
very different from `refGrayVal`

), the weight value
is small.

computes
the pixel weights, where the reference grayscale intensity value is
the average of the intensity values of all the pixels in `W`

= graydiffweight(`I`

,`mask`

)`I`

that
are marked as logical `true`

in `mask`

.
Using the average of several pixels to calculate the reference grayscale
intensity value can be more effective than using a single reference
intensity value, as in the previous syntax.

computes
the pixel weights, where the reference grayscale intensity value is
the average of the intensity values of the pixel locations specified
by the vectors `W`

= graydiffweight(`I`

,`C`

,`R`

)`C`

and `R`

. `C`

and `R`

contain
the column and row indices of the pixel locations that must be valid
pixel indices in `I`

.

returns
the weight array `W`

= graydiffweight(___, `Name,Value`

)`W`

using name-value pairs to
control aspects of weight computation.