plz help me sorting the error...

the code i wrote is:
S(y,x)=0.125*f(y,mod(x-p-2,N)+1)+...
0.375*f(y,x)+...
0.375*f(y,mod(x+p,N)+1)+...
0.125*f(y,mod(x+p*2+1,N)+...
0.125*f(mod(y-p-2,N)+1,x)+...
0.375*f(y,x)+...
0.375*f(mod(y+p,N)+1,x)+...
0.125*f(mod(y+p*2+1,N)+1,x));
here f() corresponds to my input image
error shown is:
Attempted to access f(1,169.125); index must be a positive integer or logical.
Error in dyadicAnalysis (line 29)
S(y,x)=0.125*f(y,mod(x-p-2,N)+1)+...
here p=2^j-1; where j is a loop variable starts from 1 and end at log(N)/log(2)
N=sizef(1), sizef=size(f);
can anybody tell me what is the problem in it? i've tried floor but the error remains the same

 Accepted Answer

Image Analyst
Image Analyst on 13 Apr 2013
There is no 169.125'th element of a matrix. You can access element # 169 or 170, but if you want to get 169.125 then you'll have to do interpolation.

13 Comments

sir hoew can i get the 169 or 170 value?
i used floor but it didnt work shows the same error....
what changes should i do in the above code corresponding to s(y,x)?
S(y,x)=0.125*f(y,mod(x-p-2,N)+1)+...
0.375*f(y,x)+...
0.375*f(y,mod(x+p,N)+1)+...
0.125*f(y,mod(x+p*2+1,N)+...
0.125*f(mod(y-p-2,N)+1,x)+...
0.375*f(y,x)+...
0.375*f(mod(y+p,N)+1,x)+...
0.125*f(mod(y+p*2+1,N)+1,x));
Explain in words what you're attempting to do with this code. Right now it just looks like alphabet soup to me.
function [wx wy]=dwt2(f)
clc;
close all;
f=rgb2gray(imread('tank.jpg'));
sizeF=size(f);
N=sizeF(1);
J=log(N)/log(2);
wx=zeros(N,N,J+1);
wy=zeros(N,N,J+1);
lambdaTable=[0.15 1.12 1.03 1.01];
figure;
imshow(f);
title('original signal');
S=zeros(N,N);
figure;
j=0;
while j<J
p=2^j-1;
lambda=1;
if j<4
lambda=lambdaTable(j+1);
end
for y=1:N
for x=1:N
wx(y,x,j+1)=(-2*f(y,x)+...
2*f(y,mod(x+p,N)+1))/lambda;
wx(y,x,j+1)=(-2*f(y,x)+...
2*f(mod(y+p,N)+1,x))/lambda;
S(y,x)=0.125*f(y,mod(x-p-2,N)+1)+...
0.375*f(y,x)+...
0.375*f(y,mod(x+p,N)+1)+...
0.125*f(y,mod(x+p*2+1,N)+...
0.125*f(mod(y-p-2,N)+1,x)+...
0.375*f(y,x)+...
0.375*f(mod(y+p,N)+1,x)+...
0.125*f(mod(y+p*2+1,N)+1,x));
end
end
subplot(J,2,j*2+1);
imshow(wx(:,:,j+1),[min(min(wx(:,:,j+1))) max(max(wx(:,:,j+1)))]);
subplot(J,2,j*2+2);
imshow(wy(:,:,j+1),[min(min(wy(:,:,j+1))) max(max(wy(:,:,j+1)))]);
f=S;
j=j+1;
end
%w(:,:,J+1)=S; figure; imshow(S,256);
angel
angel on 13 Apr 2013
Edited: angel on 13 Apr 2013
this is my code sir for dyadic wavelet transform for 2D image...
sir where should i adjust the function floor so that it can work properly. the problem is in s(y,x)
reply soon
angel, I don't have the wavelet toolbox so I can't help with wavelets. Plus you didn't put in an explanation like I requested. Do you know how to use the debugger to step through your code and examine variables? Please see : http://blogs.mathworks.com/videos/2012/07/03/debugging-in-matlab/ if you aren't using debugging skills right now.
pammy, I don't know. Are you talking about the same code as angel? If so, you'll have to follow up with angel. Are you and angel working together, or have the same assignment in the same class? It's not tagged as homework, so probably not. Do you work for the same company then?
angel
angel on 14 Apr 2013
Edited: angel on 14 Apr 2013
sir i've used the dubugger the above error i sorted it out but the error given below i didnt
Error using imshow>preParseInputs (line 385)
The syntax IMSHOW(I,N) has been removed.
Error in imshow (line 194)
varargin_translated = preParseInputs(varargin{:});
Error in dyadicAnalysis (line 56)
imshow(S,256);
385 error(message('images:removed:syntaxNoReplacement','IMSHOW(I,N)'))
K>>
the following is my code
function [wx wy]=dwt2(f)
clc;
close all;
f=rgb2gray(imread('tank.jpg'));
sizeF=size(f);
N=sizeF(1);
J=ceil(log(N)/log(2));
wx=zeros(N,N,J+1);
wy=zeros(N,N,J+1);
lambdaTable=[0.15 1.12 1.03 1.01];
figure;
imshow(f);
title('original signal');
S=zeros(N,N);
figure;
j=0;
while j<J
p=2^j-1;
lambda=1;
if j<4
lambda=lambdaTable(j+1);
end
for y=1:N
for x=1:N
wx(y,x,j+1)=(-2*f(y,x)+...
2*f(y,mod(x+p,N)+1))/lambda;
wx(y,x,j+1)=(-2*f(y,x)+...
2*f(mod(y+p,N)+1,x))/lambda;
S(y,x)=0.125*f(y,mod(x-p-2,N)+1)+...
0.375*f(y,x)+...
0.375*f(y,mod(x+p,N)+1)+...
0.125*f(y,mod(x+p*2+1,N)+1)+...
0.125*f(mod(y-p-2,N)+1,x)+...
0.375*f(y,x)+...
0.375*f(mod(y+p,N)+1,x)+...
0.125*f(mod(y+p*2+1,N)+1,x);
end
end
dbstop if error
subplot(J,2,j*2+1);
imshow(wx(:,:,j+1),[min(min(wx(:,:,j+1))) max(max(wx(:,:,j+1)))]);
subplot(J,2,j*2+2); % showing error
imshow(wy(:,:,j+1),[min(min(wy(:,:,j+1))) max(max(wy(:,:,j+1)))]);
f=S;
j=j+1;
end
%w(:,:,J+1)=S; figure; imshow(S,256);
problem in the imshow function plz tell me what should i modify in the code so that my code can work fine
reply soon
Why not just use
imshow(wy(:,:,j+1), []);
You don't need to calculate the min and max - it will do it for you.
the problem is in the last line sir
imshow(S,256)
Error using imshow>preParseInputs (line 385)
The syntax IMSHOW(I,N) has been removed.
Error in imshow (line 194)
varargin_translated = preParseInputs(varargin{:});
Error in dyadicAnalysis (line 56)
imshow(S,256);
385 error(message('images:removed:syntaxNoReplacement','IMSHOW(I,N)'))
K>>
Modify your code to
imshow(S, [])
thank u so much sir.......
Error using imshow>preParseInputs (line 425) IMSHOW expected at least 1 input argument but was called instead with 0 input arguments.
Error in imshow (line 214) varargin_translated = preParseInputs(varargin{:}); while running the code i am facing this error please help me in sorting out this error
Aqsa Ali: which code are you using? Please post it.

Sign in to comment.

More Answers (0)

Categories

Tags

Community Treasure Hunt

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

Start Hunting!