Displaying a curved image of a gradient image in MATLAB

I have an image. I want to display a curved plot of a gradient image that I get using a gradient function in MATLAB, preferably overlaid on a 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 have tried and all I get is a completely blue display.

0


source to share


1 answer


I think all you see are arrows, but they are too close together. If you draw two graphs ( imshow(g)

and quiver

) separately, they appear normal. Imshow only shows pixels without any scaling, if you fix that (make the scale) the quiver arrows will also have more space between them and become visible. You can do this by adding a parameter 'InitialMagnification','fit'

to imshow:

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

      



Or you can show fewer 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)));

      

+3


source







All Articles