Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: Out of bound Error
Replies: 5   Last Post: Feb 20, 2013 1:18 PM

 Messages: [ Previous | Next ]
 Jerome Posts: 48 Registered: 12/9/11
Re: Out of bound Error
Posted: Feb 20, 2013 11:10 AM

The size of cyy however, is 700 x 900

"Jerome " <the_rome@hotmail.com> wrote in message <kg2pl4\$803\$1@newscl01ah.mathworks.com>...
> I get the following error and I am unsure how to fix it. I tried to edit the rows and cols but it seems not to work. Does anyone know a quick fix to this problem:
>
> ??? Attempted to access cyy(1,901); index out of bounds because
> size(cyy)=[700,900].
>
> Error in ==> snake at 31
> eterm(i,j) = (cyy(i,j)*cx(i,j)*cx(i,j) -2
> *cxy(i,j)*cx(i,j)*cy(i,j) +
> cxx(i,j)*cy(i,j)*cy(i,j))/((1+cx(i,j)*cx(i,j) +
> cy(i,j)*cy(i,j))^1.5);
>
>
> The following code is listed below:
>
> %parameters
> N = 100;
> smth = rgb2gray(image);
>
> % Calculating size of image
> [row col] = size(image);
>
> eline = smth; %eline is simply the image intensities
>
>
>
> m1 = [-1 1];
> m2 = [-1;1];
> m3 = [1 -2 1];
> m4 = [1;-2;1];
> m5 = [1 -1;-1 1];
>
> cx = conv2(smth,m1,'same');
> cy = conv2(smth,m2,'same');
> cxx = conv2(smth,m3,'same');
> cyy = conv2(smth,m4,'same');
> cxy = conv2(smth,m5,'same');
>
> for i = 1:row
> for j= 1:col-1
> % eterm as deined in Kass et al Snakes paper
> eterm(i,j) = (cyy(i,j)*cx(i,j)*cx(i,j) -2 *cxy(i,j)*cx(i,j)*cy(i,j) + cxx(i,j)*cy(i,j)*cy(i,j))/((1+cx(i,j)*cx(i,j) + cy(i,j)*cy(i,j))^1.5);
> end
> end

Date Subject Author
2/20/13 Jerome
2/20/13 dpb
2/20/13 Jerome
2/20/13 dpb
2/20/13 Jerome
2/20/13 Jerome