Path: news.mathworks.com!not-for-mail From: "arron lacey" <arronslacey@gmail.com> Newsgroups: comp.soft-sys.matlab Subject: Re: error with cross product Date: Fri, 16 Mar 2012 11:15:22 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 40 Message-ID: <jjv7ca$he7$1@newscl01ah.mathworks.com> References: <jju0ql$qjs$1@newscl01ah.mathworks.com> <jju58u$9v9$1@newscl01ah.mathworks.com> Reply-To: "arron lacey" <arronslacey@gmail.com> NNTP-Posting-Host: www-03-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: newscl01ah.mathworks.com 1331896522 17863 172.30.248.48 (16 Mar 2012 11:15:22 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Fri, 16 Mar 2012 11:15:22 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 1914405 Xref: news.mathworks.com comp.soft-sys.matlab:761172 "Roger Stafford" wrote in message <jju58u$9v9$1@newscl01ah.mathworks.com>... > "arron lacey" <arronslacey@gmail.com> wrote in message <jju0ql$qjs$1@newscl01ah.mathworks.com>... > > Hi guys, what's the error for here? > > > > Img = imread('littlesquare.png'); > > Img = Img(:,:,1); > > Img = double(Img); > > [x,y] = size(Img); > > I = ones(x,y); > > > > [R, L] = bwdist(Img); > > Rmag = bwdist(R); > > imshow(Rmag, []); > > B = cross(Img,Rmag); > > imshow(B) > > > > I'm getting: > > > > ??? Error using ==> cross at 37 > > A and B must have at least one dimension of length 3. > > > > even though imshow shows the expected image... > - - - - - - - - - > That error message means just what it says! One of the dimensions in each argument must have size 3. Cross products are really defined only in three-dimensional space. The cross product of two vectors in 3D is a third vector (also in 3D) orthogonal to those two vectors and having a length equal to the product of the two vectors' lengths times the sine of the angle between them and pointing in a right-hand sense. How are you going to define it with two images? Your code makes no sense. If you had left all three colors in, you would get a result though I am not sure what its significance would be. > > Roger Stafford I think there is a deeper problem than that. Even if I have: Img = imread('littlesquare.png'); Img = Img(:,:,1); Img = double(Img); [x,y,z] = size(Img); I = ones(x,y,z); Rmag = bwdist(R); imshow(Rmag, []); B = cross(Img,Rmag); I still get the same error. I am beginning to think that bwdist does not return a vector field.....