Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Please Tell me is my Code Correct cause it seems there is something logically wrong Thanx

Subject: Please Tell me is my Code Correct cause it seems there is something logically wrong Thanx

From: Twilighter

Date: 14 Jun, 2011 11:02:04

Message: 1 of 5

Please Help me out in this

i have equation which i already implemented it
i just need to know is my basics are correct or not
because the output results are driving me mad already

here are my equations
https://picasaweb.google.com/105826940471714630965/Jun132011?authkey=Gv1sRgCJjQ_IeY5eWhrAE#5617463216234100178

the First one Eq. 9 cross correlation between two images 256x256 & 64x64
in two DWT subbands that's why there is the theta

X(i,j) .... is supposed to be the decomposed coefficients of the main image 256x256
and x(i,j) is the 64x64

i take cH1, cV1 to cross-correlate them only

well u can ignore the subband part and consider it a cross-correlation between two images only ... just i need to know is my choose to this function is correct

this its Code

cross_correlation_h = xcorr2(cH1,imgx);
cross_correlation_v = xcorr2(cV1,imgx);
cross_correlation_h = sum(sum(cross_correlation_h));
cross_correlation_v = sum(sum(cross_correlation_v));

ConstMultiply = 3*256*256;
ConstMultiply = 1/ConstMultiply;

cross_correlation = ConstMultiply*((cross_correlation_h+cross_correlation_h));


For Equation 10,11

this is my code

ccHThr= zeros(1,256*256);
ccVThr= zeros(1,256*256);

cH1 = reshape(cH1,1,256*256);
cV1 = reshape(cV1,1,256*256);

% initalize message to all ones
message_vector=ones(1,256*256);

for (KK=1:length(message_vector))
    
        ccHThr(KK)=ccHThr(KK)+(cH1(KK))^2;
        ccVThr(KK)=ccVThr(KK)+(cV1(KK))^2;
end

ConstMultiply = (3*256*256)^2;
ConstMultiply = 1/ConstMultiply;
T1=ConstMultiply *sum(ccHThr+ccVThr);
T = 3.97*sqrt(2*T1);


please tell me this code correctly implement the mentioned equations, or there is something logically wrong?

also if i need to cross-correlate those two images as in in equation1 manually i mean without using the Matlab function, how can it be done

Hope i have explained my point clearly

and hope to receive many of your positive responses

thanx :)

Subject: Please Tell me is my Code Correct cause it seems there is something logically wrong Thanx

From: Steven_Lord

Date: 14 Jun, 2011 13:52:43

Message: 2 of 5



"Twilighter " <mscmatlab@gmail.com> wrote in message
news:it7f3c$lu8$1@newscl01ah.mathworks.com...
> Please Help me out in this
>
> i have equation which i already implemented it
> i just need to know is my basics are correct or not
> because the output results are driving me mad already

*snip*

Then you need to test and debug your code. Developing the skills required to
test and debug your code now will help you greatly in the future. Start off
with a problem for which you know the answer; does your code give the
correct answer in that known case? If not, you need to step through your
code, examining the results after each step and locating where the answer
starts to diverge from what you expect. Then you need to determine why it
diverges.

The debugging capabilities in MATLAB will help you do this:

http://www.mathworks.com/help/techdoc/matlab_env/brqxeeu-175.html

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Please Tell me is my Code Correct cause it seems there is something logically wrong Thanx

From: Twilighter

Date: 14 Jun, 2011 18:25:05

Message: 3 of 5

thank you Steve i do know about code debugging & i do trace my code, but i'm just new to Matlab & i could be not that good in math ... so i apply thing wrong

thats why i asked if i did put the equations correctly in code

and i know they are so simple

i also want to make cross-correlation to the images in code not by the matlab function

thanx for your tips :)

Subject: Please Tell me is my Code Correct cause it seems there is

From: ImageAnalyst

Date: 14 Jun, 2011 22:46:56

Message: 4 of 5

How do you know it's wrong?

Subject: Please Tell me is my Code Correct cause it seems there is

From: Twilighter

Date: 14 Jun, 2011 23:48:04

Message: 5 of 5

because the first equation should give me something called image response

and the second is called threshold

and their values should be pretty close

what i'm trying to simulate its values between 0.3 & 6 for both the response & threshold

while my values for image response is like 100 to 600

and the threshold is multiplied by 10^-3

and the images are the same, so there must be something wrong in my coding to the equations?

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us