在MATLAB中显示渐变图像的颤动图 [英] Displaying a quiver plot of a gradient image in MATLAB

查看:51
本文介绍了在MATLAB中显示渐变图像的颤动图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张图片.我想显示在MATLAB中使用梯度函数获得的梯度图像的颤动图,最好叠加在梯度图像上.

I have an image. I want to display a quiver plot of the gradient image that I get using gradient function in MATLAB, preferably superimposed on the gradient image.

I = imread('image.png');
[gx,gy] = gradient(double(rgb2gray(I)));
g = abs(gx) + abs(gy);
figure;
imshow(g, []);
hold on;
quiver(abs(gx),abs(gy));

这是我尝试过的,我得到的只是一个全蓝色的显示屏.

This is what I tried, and all I get is a completely blue display.

推荐答案

我认为您所看到的只是箭头,但它们太靠近了. 如果分别绘制两个图(imshow(g)quiver),它们将显示为法线. imshow仅显示没有任何缩放比例的像素,如果您将其固定(使其缩放),则颤动箭头之间也将具有更大的间距并变得可见. 您可以通过在imshow中添加'InitialMagnification','fit'选项来做到这一点:

I think all you see is the arrows, but they're too close together. If you plot the two graphs (imshow(g) and quiver) separately, they show up normal. The imshow only shows the pixels without any scaling, if you fix that (make it scale) the quiver arrows also will have more space between them and become visible. You can do just that by adding the 'InitialMagnification','fit' option to imshow:

imshow(g,'InitialMagnification','fit')

或者您可以显示较少的箭矢箭头:

Or you can show less quiver arrows:

figure;
imshow(g, []);  % [] to display image properly     
hold on;

[Nx, Ny] = size(g);
xidx = 1:10:Nx;
yidx = 1:10:Ny;
[X,Y] = meshgrid(xidx,yidx);
quiver(Y',X',abs(gx(xidx,yidx)),abs(gy(xidx,yidx)));

这篇关于在MATLAB中显示渐变图像的颤动图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆