Path: news.mathworks.com!not-for-mail
From: "Selwyna Bas" <gracelin@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to find Horizontal & Vertical Gradients?
Date: Sun, 6 Jan 2008 08:49:53 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 57
Message-ID: <flq4nh$81v$1@fred.mathworks.com>
References: <fd664390-3ad5-4a89-9f65-a824f963677c@q39g2000hsf.googlegroups.com> <flovn7$102o$1@f04n12.cac.psu.edu>
Reply-To: "Selwyna Bas" <gracelin@mathworks.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1199609393 8255 172.30.248.35 (6 Jan 2008 08:49:53 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 6 Jan 2008 08:49:53 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1227919
Xref: news.mathworks.com comp.soft-sys.matlab:444521


dvt <dvt+usenet@psu.edu> wrote in message <flovn7
$102o$1@f04n12.cac.psu.edu>...
> selvi wrote:
> > Hi,
> >    I want to implement the following Equations in 
MATLAB to find hori
> > & Vert Gradient.
> > 
> > DH = | x(i , j-2) + x(i ,,j+2) - 2x(i, j) |  +  | x
(i,,j-1) - x(i,,j
> > +1) |
> > 
> > DV = | x(i-2, j) + x(i+2,,j) - 2x(i, j) |  +  | x(i-1, 
j) - x(i+1,,j)
> > |
> > 
> > If(DH+35< DV)
> > 
> >    G={ [ x(i,,j-1) + x(i,,j+1) ] /2 }    +   { [ 2x(i, 
j) - x(i , j-2)
> > - x(i ,,j+2) ]/4}
> 
> If I understand your question, try something like the 
following:
> 
> x = rand(10);
> Ga = zeros(10); %preallocate
> DHa = Ga;
> DVa = Ga;
> 
> i = 3:8;
> j = 3:8;
> DH(i,j) = abs( x(i,j-2) + x(i,j+2) - 2*x(i,j) )  +...
>      abs( x(i,j-1) - x(i,j+1) );
> DV(i,j) =abs( x(i-2,j) + x(i+2,j) - 2*x(i,j) )  +...
>      abs( x(i-1,j) - x(i+1,j) );
> mask = ((DH+35)< DV);
> G(i,j) = ( x(i,j-1) + x(i,j+1) ) /2 +...
>      ( 2*x(i,j) - x(i,j-2) - x(i,j+2) )/4;
> G = mask .* G;
> 
> As Roger pointed out, you should look into the meanings 
of {}, [], and 
> () in Matlab.
> -- 
> Dave
> dvt at psu dot edu

What is the meaning of G = mask .* G;
Also explain whats the neccesity of this?
 x = rand(10);
> Ga = zeros(10); %preallocate
> DHa = Ga;
> DVa = Ga;
 pl explain..  
Thanku for your help