superimpose quiver plot onto image

Hi,
Does anyone know a way of superimposing the gradient vector field of an image onto the image itself? As far as I can tell, the "quiver" function should allow this, but I cannot get it to work... it just shows a blue figure. This is the code I am using:
img = imread('bubbles.jpg');
ycbcr = rgb2ycbcr(img);
lum = ycbcr(:,:,1);
[gx gy] = gradient(lum);
figure('name','Gradient');
imshow(dens,[],'InitialMagnification','fit');
hold on;
quiver(gx(1:r,1:c),gy(1:r,1:c));
title('Gradient Field');
Thanks for any help you are able to give me.

回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 5 月 20 日

0 投票

Here is the complete solution script:
img = imread('Bubble0.jpg');
GI = rgb2gray(img);
[gx, gy] = gradient(double(GI), .5, .5);
[r, c, LA]=size(img);
figure('name','Gradient');
imshow(img(1:r,1:c),'InitialMagnification','fit');
hold on;
quiver(gx(1:r,1:c),gy(1:r,1:c), 1);
title('Gradient Field');
figure
quiver(gx(1:r,1:c),gy(1:r,1:c), 10);
title('Gradient Field')

カテゴリ

ヘルプ センター および File ExchangeVector Fields についてさらに検索

質問済み:

2011 年 2 月 21 日

回答済み:

2021 年 5 月 20 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by