Radial gradient using Convolution

조회 수: 3 (최근 30일)
RUPESH
RUPESH 2013년 4월 25일
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..

답변 (1개)

Image Analyst
Image Analyst 2013년 4월 25일
편집: Image Analyst 2013년 4월 25일
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
Cedric
Cedric 2013년 4월 25일
편집: Cedric 2013년 4월 25일
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)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by