How to Normalize co-ordinates to [-sqrt2,sqrt2]?
조회 수: 5 (최근 30일)
이전 댓글 표시
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
dpb
2015년 2월 13일
Well, how about trying a sample case at the command line and see?
BIG HINT: What's the value of [1-(1)'?
채택된 답변
Eduardo Márquez
2015년 2월 13일
편집: Eduardo Márquez
2015년 2월 13일
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
Eduardo Márquez
2015년 2월 13일
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
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!