Radial gradient using Convolution
Afficher commentaires plus anciens
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..
Réponses (1)
Image Analyst
le 25 Avr 2013
Modifié(e) : Image Analyst
le 25 Avr 2013
0 votes
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 commentaire
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)

Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!