imgradientxy - 图文

发布时间 : 星期二 文章imgradientxy - 图文更新完毕开始阅读

imgradientxy

Directional gradients of an image

collapse all in page

Syntax

? [Gx,Gy] = imgradientxy(I)

example

? [Gx,Gy] = imgradientxy(I,method)

example

?

[gpuarrayGx,gpuarrayGy] = imgradientxy(gpuarrayI,___)

example

Description

[Gx,Gy] = imgradientxy(I) returns the directional gradients, Gx and Gy, the

same size as the input image I.

When applying the gradient operator at the boundaries of the image, values outside the bounds of the image are assumed to equal the nearest image border value.

[Gx,Gy] = imgradientxy(I,method) returns the directional gradients using the

specified method.

[gpuarrayGx,gpuarrayGy] = imgradientxy(gpuarrayI,___) performs the operation

on a GPU. The input image and the return values are gpuArrays. This syntax requires the Parallel Computing Toolbox?

Examples

example

example

example

collapse all

Calculate directional gradients

Read image.

I = imread('coins.png');

Calculate gradient magnitude and gradient direction using Prewitt's gradient operator

[Gx, Gy] = imgradientxy(I,'prewitt');

figure; imshowpair(Gx, Gy, 'montage');

title('Directional Gradients: x-direction, Gx (left), y-direction, Gy (right), using Prewitt method') axis off;

Calculate directional gradients on a GPU

Read image into a gpuArray.

I = gpuArray(imread('coins.png'));

imshow(I)

Calculate gradient magnitude and gradient direction using Prewitt's gradient operator and display images.

[Gx, Gy] = imgradientxy(I,'prewitt');

figure, imshow(Gx, []), title('Directional gradient: X axis') figure, imshow(Gy, []), title('Directional gradient: Y axis')

Display gradient magnitude and direction in addition to directional gradients

Read image and return directional gradients, Gx and Gx, as well as gradient magnitude and direction, Gmag and Gdir, utilizing default Sobel gradient operator.

I = imread('coins.png'); [Gx, Gy] = imgradientxy(I); [Gmag, Gdir] = imgradient(Gx, Gy);

figure; imshowpair(Gmag, Gdir, 'montage'); axis off;

title('Gradient Magnitude, Gmag (left), and Gradient Direction, Gdir (right), using Sobel method')

figure; imshowpair(Gx, Gy, 'montage'); axis off;

title('Directional Gradients, Gx and Gy, using Sobel method')

Calculate gradient magnitude and direction in addition to directional gradients on a GPU

Read image and return directional gradients, Gx and Gx, as well as gradient magnitude and direction, Gmag and Gdir, utilizing default Sobel gradient operator.

联系合同范文客服:xxxxx#qq.com(#替换为@)