How to Normalize co-ordinates to [-sqrt2,sqrt2]?
    3 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
I have got the following code
d    = size(img);      % dimension
img    = double(img);
xstep    = 2/(d(1)-1);
ystep    = 2/(d(2)-1);
[x,y]    = meshgrid(-1:xstep:1,-1:ystep:1);
How does this normalisation actually works? Can any one please help.
1 commentaire
  dpb
      
      
 le 13 Fév 2015
				Well, how about trying a sample case at the command line and see?
BIG HINT: What's the value of [1-(1)'?
Réponse acceptée
  Eduardo Márquez
      
 le 13 Fév 2015
        
      Modifié(e) : Eduardo Márquez
      
 le 13 Fév 2015
  
      As I see it, this normalizing the domain of the image, not the image, ie, seeks to center the coordinate (0,0).
[ 1:-1, -1:1] as the domain you want, take the d (1) -1 to count 0. If only outside [0:1,0:1] simply to know the step calculated 1 / (d (1) -1), but as it wants to [-1: 1] requires doubling leave half of steps on one side and half on the other. 2 / (d (1) -1), double spaces become large and occupy the range [-1:1].
Then meshgrid generate matrix with you new domain, instead of going to [1:d(1),1:d(2)] was added to the domain [-1:1,-1:1].
Read meshgrid function to know who works.
I hope to help.
Example:
Image is 3x3, then d=[3 3 1];
The image domain is [(1,1) (1,2) (1,3);(2,1) (2,2) (2,3);(3,1) (3,2) (3,3)];
The meshgrid generate the domain [(-1,-1) (-1,0) (-1,1) : (0,-1) (0,0) (0,1) :(1,-1) (1,0) (1,1)];
3 commentaires
  Eduardo Márquez
      
 le 13 Fév 2015
				Calculates the distance from one point to another, in the example d = [3 3 1];
xstep = 2 / (3-1) = 2/2 = 1, that is, starts at -1 meshgrid adding 1 up to 1, therefore, the new domain are [-1, -1 + 1, -1 + 1 + 1] = [- 1,0,1]
If d = [5 5 1]; xstep = 2 / (5-1) = .5, the new domain [-1, -1 + 0.5, -1 +.5+. 5 ...] = [-1, -.5,0,.5,1];
analogous in ystep
Plus de réponses (0)
Voir également
Catégories
				En savoir plus sur White dans Help Center et File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


