나는 위치 격자를 가지고 가고, 그 후에 각 화소에서 정상화 한 거리를 산출하는 것을 시도하고있다. 나는 3 × 3 이미지 (크기 (IM)) 나는 다른 모든 픽셀로 정규화 된 거리를 얻을의 첫 번째 픽셀을 가지고가는 경우에matlab : 정규화 된 거리지도
clear all;
im = imread('test1.png'); % read in the image
im = im(:,:,1); %vectorize image
n = size(im,1); % No of grids in the X-Y plane
xp(1:n)=1:1:n; % Y-coordinates of the plane where we are interested
yp(1:n)=1:1:n;% X-coordinates of the plane where we are interested
Y(1:n,1:n)=0; % This array is for 1-d to 2-d conversion of coordinates
X(1:n,1:n)=0;
for i=1:n
Y(i,:)=yp(i); % all y-coordinates value in 2-d form
end
for i=1:n
X(:,i)=xp(i);% all x-coordinates value in 2-d form
end
Z = zeros(size(X)); % Z dimension is appended to 0
pos = [X(:),Y(:),Z(:)]; %position co-ordinates for x y z dimensions
N = size(pos,1); % size of position matrix
v = cell(N,1); %define cell for storage of x-y plane direction vectors
for j = 1:N
for i = 1:N
vecdir(i,:) = pos(i,:) - pos(j,:); %direction of vectors between each point in the x-y plane
dist(i,:) = pdist2(pos(i,:),pos(j,:)); %distance between each point in the x-y plane
norm(i,:) = vecdir(i,:)./(dist(i,:)).^2; %normalised distance between each point in the x-y plane
end
v{j} = vecdir;
d{j} = dist;
r{j} = norm; %store normalised distances into a cell array
end
R = cellfun(@isnan,r,'Un',0);
for ii = 1:length(r)
r{ii}(R{ii}) =0;
end
(에 :이 그것을 할 올바른 방법이 있는지 확실하지 않습니다 같은 XYZ 위치 형식) :
>> r{1}
ans =
0 0 0
0 1.0000 0
0 0.5000 0
1.0000 0 0
0.5000 0.5000 0
0.2000 0.4000 0
0.5000 0 0
0.4000 0.2000 0
0.2500 0.2500 0
가 난 그냥이 권리도이 단계에서 효율성에 대한 참을수없는 방법으로()
정규화 된 거리의 의미는 무엇입니까? 정규화 된 평균은 보통 0과 1 사이이지만 최소값과 최대값은 무엇을 의미합니까? –
안녕 Gunther - 네, 그게 전부입니다. 그리드의 두 점 사이의 단위 벡터 방향을 두 점 사이의 거리로 나눈 값입니다. 제 경우에는 거리 제곱으로 나눕니다. – brucezepplin
아니요, 결과는 단위 벡터입니다. 이제 실제 거리 벡터가 있으므로, 실제 거리 벡터의 2- 노름으로 나눕니다. 내가 맞습니까? 또한 내 대답에 업데이 트를 참조하십시오 –