Radial gradient using Convolution
4 views (last 30 days)
Show older comments
Hi, I have color images(here I), and considering its Green(G) channel and following is the part of code:
I=I(:,:,2);
dx=[-1 0 0;-1 8 -1;-1 0 0];
dy=[1 0 0;-1 8 -1;1 0 0];
s = [1 ; 1];
gx = conv2(conv2(double(I),dx,'same'),s,'same');
gy = conv2(conv2(double(I),dy,'same'),s','same');
now my question is: -- What gx and gy is giving here, is it a radial gradient??
-- And what will be there if convolved once only ?
Thanks..
0 Comments
Answers (1)
Image Analyst
on 25 Apr 2013
Edited: Image Analyst
on 25 Apr 2013
Why are you convolving twice? You're taking the output of conv() and convolving it again. And why not just use imgradent() or imgradentxy()? I don't know what radial gradient is. The gradient is the maximum slope and it has a specified direction. If you say, x or y, then it's the max slope in the x or y direction. But the radial direction? That's all directions and I think that would just be the same as the normal, regular gradient.
1 Comment
Cedric
on 25 Apr 2013
Edited: Cedric
on 25 Apr 2013
Any function that depends on the norm of x-x0 only expresses what seems to be named "radial gradient" (around x0) in drawing applications. We might owe this terminology to Mac Paint 1986 or something like that ;-)
[X,Y] = meshgrid(-7:0.1:7, -5:0.1:5) ;
nrm = sqrt(X.^2 + Y.^2) ;
R = (sin(nrm)+1) ./ sqrt(nrm) ;
G = (sin(nrm+2*pi/3)+1) ./ sqrt((nrm+2*pi/3)) ;
B = (sin(nrm+4*pi/3)+1) ./ sqrt((nrm+4*pi/3)) ;
img = cat(3, R, G, B) ;
imshow(img)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!