imgradientxy - 图文

2026/1/27 7:46:07

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.


imgradientxy - 图文.doc 将本文的Word文档下载到电脑
搜索更多关于: imgradientxy - 图文 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219