From: Krishna Prasad Satamraju on
Hi all,
I'm new to Matlab Image Processing. I'm trying to filter an image using Avg Filtering Technique.
close all;
clear all;
int i;
x = imread('D:\image processing\test11.jpg');

xd = im2double(x);
[h, w] = size(xd);
%imshow(xd);
hist(xd);
hx = [1/9 1/9 1/9; 1/9 1/9 1/9; 1/9 1/9 1/9]; (This is Filter Mask)

for v = 1:h-2
for u = 1:w-2
for i=0:3
for j=0:3
ifv = xd(u+i, v+j).* hx(i,j);
end
end
end
end
It is giving me the following error..
??? Attempted to access hx(0,0); index must be a positive integer or logical.

Error in ==> kp1 at 16
ifv = xd(u+i, v+j).* hx(i,j);

Please help me in out from this error .. Thanks in advance.
From: Steven Lord on

"Krishna Prasad Satamraju" <kpsatamraju(a)gmail.com> wrote in message
news:hu383s$qev$1(a)fred.mathworks.com...
> Hi all,
> I'm new to Matlab Image Processing. I'm trying to filter an image using
> Avg Filtering Technique.

*snip*

> It is giving me the following error.. ??? Attempted to access hx(0,0);
> index must be a positive integer or logical.
>
> Error in ==> kp1 at 16
> ifv = xd(u+i, v+j).* hx(i,j);
>
> Please help me in out from this error .. Thanks in advance.

MATLAB uses 1-based indexing, not 0-based -- that means the first element of
a matrix in MATLAB is the element in position (1, 1). Modify your code
appropriately.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com


From: Wayne King on
"Krishna Prasad Satamraju" <kpsatamraju(a)gmail.com> wrote in message <hu383s$qev$1(a)fred.mathworks.com>...
> Hi all,
> I'm new to Matlab Image Processing. I'm trying to filter an image using Avg Filtering Technique.
> close all;
> clear all;
> int i;
> x = imread('D:\image processing\test11.jpg');
>
> xd = im2double(x);
> [h, w] = size(xd);
> %imshow(xd);
> hist(xd);
> hx = [1/9 1/9 1/9; 1/9 1/9 1/9; 1/9 1/9 1/9]; (This is Filter Mask)
>
> for v = 1:h-2
> for u = 1:w-2
> for i=0:3
> for j=0:3
> ifv = xd(u+i, v+j).* hx(i,j);
> end
> end
> end
> end
> It is giving me the following error..
> ??? Attempted to access hx(0,0); index must be a positive integer or logical.
>
> Error in ==> kp1 at 16
> ifv = xd(u+i, v+j).* hx(i,j);
>
> Please help me in out from this error .. Thanks in advance.

Hi, Matlab indexes from 1, not zero.
for i=0:3
for j=0:3

Wayne