You are here : matlab → Image Processing → gradientweight
# gradientweight() - Image Processing

### Syntax

### Example

### Output / Return Value

### Limitations

### Alternatives / See Also

### Reference

W = gradientweight(I) calculates the pixel weight for each pixel in image I based on the gradient magnitude at that pixel, and returns the weight array W. The weight of a pixel is inversely related to the gradient values at the pixel location. Pixels with small gradient magnitude (smooth regions) have a large weight and pixels with large gradient magnitude (such as on the edges) have a small weight.W = gradientweight(I,sigma) uses sigma as the standard deviation for the Derivative of Gaussian that is used for computing the image gradient.exampleW = gradientweight(___,Name,Value,...) returns the weight array W using name-value pairs to control aspects of weight computation.

W = gradientweight(I)W = gradientweight(I,sigma)W = gradientweight(___,Name,Value,...) example

Segment Image Using Weights Derived from Image GradientOpen This Example This example segments an image using the Fast Marching Method based on the weights derived from the image gradient. Read image and display it.I = imread('coins.png'); imshow(I) title('Original Image') Compute weights based on image gradient.sigma = 1.5; W = gradientweight(I, sigma, 'RolloffFactor', 3, 'WeightCutoff', 0.25); Select a seed location.R = 70; C = 216; hold on; plot(C, R, 'r.', 'LineWidth', 1.5, 'MarkerSize',15); title('Original Image with Seed Location') Segment the image using the weight array.thresh = 0.1; [BW, D] = imsegfmm(W, C, R, thresh); figure, imshow(BW) title('Segmented Image') hold on; plot(C, R, 'r.', 'LineWidth', 1.5, 'MarkerSize',15); Geodesic distance matrix D can be thresholded using different thresholds to get different segmentation results.figure, imshow(D) title('Geodesic Distances') hold on; plot(C, R, 'r.', 'LineWidth', 1.5, 'MarkerSize',15);