Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Difficulty in matlab coding

Status
Not open for further replies.

Anney

Newbie level 3
Joined
Jul 12, 2011
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,308
Hi

I am tring to perform a coding of the below equations which basically is an enhancement operation of an image called Single Scale Retinex.

The Single Scale retinex is given by

Ri (x,y)=log Ii (x,y) – log [F(x,y) * Ii (x,y) ]

Where

F(x,y) = K exp(-r2 / c2 )--- Surround Function
c- Scalar value and selection of K is that
r- √ x2 + y2
∫∫ F(x,y) dx dy =1


The problem I have is , I am not able to find the value of F(x,y) (surround function) with the integration condition....


Could somebody help me with this
Thank you
 

zorro

Advanced Member level 4
Joined
Sep 6, 2001
Messages
1,131
Helped
356
Reputation
710
Reaction score
298
Trophy points
1,363
Location
Argentina
Activity points
8,902
Hi Anney,

Welcome to Edaboard!
If there is no a typo and I'm not wrong, you equation reduces (assuming natural log) to

Ri (x,y) = -log(K) + r2/c2

Regards

Z
 
  • Like
Reactions: Anney

    Anney

    points: 2
    Helpful Answer Positive Rating

ferdem

Advanced Member level 4
Joined
Oct 18, 2008
Messages
114
Helped
29
Reputation
58
Reaction score
26
Trophy points
1,308
Location
Türkiye
Activity points
2,261
I did not understand what your problem exactly is. Is it integration in 2D in MATLAB? If you want to integrate two-variable functions over rectangular areas, you can make use of "meshgrid" function. Below lines may give you an idea.
[x,y]=meshgrid(-5:0.1:5,-10:0.1:10); % x,y grid for two independent variable is created.
r=sqrt(x.^2+y.^2) % norms of points are stored
 
  • Like
Reactions: Anney

    Anney

    points: 2
    Helpful Answer Positive Rating

Anney

Newbie level 3
Joined
Jul 12, 2011
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,308
@Zorro and Ferdem

Thanks for replying me.....I will try working on your suggestions

Actually I need to solve for Ri(x,y) with those conditions and my difficulty is in 2D integration.

Using meshgrid I agree ,I can find r...which on substituting in F(x,y) = k exp(-r.^2/c.^2)....[[c is any scalar value]]

now to find the value of k i use the integration condition ∫∫ F(x,y) dx dy =1

ie k=1/∫∫ (exp(-r.^2/c.^2))

My problem is I dont know how to satisfy this condition and subsitute in
Ri (x,y)=log Ii (x,y) – log [F(x,y) * Ii (x,y) ]

I get errors while coding this part....Can anyone send me the matlab code for this .

Regards
Anney

---------- Post added at 13:33 ---------- Previous post was at 13:13 ----------

Hi adding some more information to the previous thread..

Ii(x,y) is the original image

* is the convolution operation

F(x,y) is the surround function calculated from F(x,y) = k exp(-r.^2/c.^2)

Thank You
Anney
 

ferdem

Advanced Member level 4
Joined
Oct 18, 2008
Messages
114
Helped
29
Reputation
58
Reaction score
26
Trophy points
1,308
Location
Türkiye
Activity points
2,261
Because I m not familiar with your subject, I can only help you about how you code math expressions in Matlab. For example you can calculatethis integral, ∫∫ (exp(-r.^2/c.^2)). You should define integration region first. Lets say: x is in between 0-5 and y 0-10.

deltax=0.1;
deltay=0.2;
c=5;
[x,y]=mesgrid(0:deltax:5,0:deltay:5);
r=sqrt(x.^2+y.^2);
integrand=(exp(-r.^2/c.^2)); %calculates values of integrand at sample points
deltas=deltax*deltay; %represents differential area in discrete domain
integral_result=sum(sum(integrand*deltas)); % sum all values (differential area times value at that point for each point!)

I did not try this code in Matlab, therefore I did not wrap it by code tags. There may be errors but I hope it helps you.
 

Anney

Newbie level 3
Joined
Jul 12, 2011
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,308
@Ferdem : thanks for the reply...will try with your suggestions

Thank You
Anney
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top