2014-12-18 2 views
2

첫 번째 볼륨을 통과하는 슬라이스 인 하나의 3D 데이터 세트와 하나의 2D 데이터 세트가 있습니다. 그들은 다른 스케일, 해상도 및 다른 좌표계에 있지만, 둘 다 나는 세계 좌표에 대한 아핀 변환을 알고 있습니다. 그런 다음 적용 방법을 알고 있다고 생각합니다. 그러나 sinc 보간법을 사용하여 변환 된 좌표에서 이미지를 다시 얻으려면 어떻게해야합니까? 나는 이것을 수행하는 방법/이것이 어떻게 작동 하는지를 배우고 싶다. 아래의 첫 번째 주석은 이미 선형 보간법을 수행하는 MATLAB 내부의 기존 함수를 지적했지만, Sinc 보간법 (및 기타)을 사용할 수 있도록이 방법을 직접 알고 싶습니다.변환 된 3D 이미지, 바람직하게는 sinc 보간에 대한 보간 또는 리샘플링 알고리즘

좌표를 반올림하고 그 값을 가져올 수 있습니다. 이는 가장 가까운 이웃 보간입니다. 계산 시간에 관계없이 가능한 한 적은 정보를 잃고 싶습니다. 그런 다음 sinc 보간법을 사용해야합니다. 변환 된 좌표를 가질 때 어떻게 보간 알고리즘을 만들 수 있습니까 (예 : sinc)?

Matlab 3D data interpolation

Nearest-neighbor interpolation algorithm in MATLAB

"Nearest neighbor"-like interpolation in MATLAB

를 : 상당히 더 도와 해달라고

%%get data 
A = rand(200,250,250); % I want to get the slice from this that corresponds to B 
B = rand(1200,1200); % I want to get the data from A that corresponds to the same pixels 

    %%get coordinates for A 
siza = size(A); clear xx;clear yy;clear zz; 
[xx,yy,zz] = meshgrid(1:siza(1), 1:siza(2), 1:siza(3)); 
coora = [xx(:)';yy(:)';zz(:)'; ones(size(zz(:)))']; 
    %%get coordinates for B 
sizb = size(B); clear xx;clear yy;clear zz; 
[xx,yy] = meshgrid(1:sizb(1),1:sizb(2)); zz = zeros(size(xx)); 
coorb = [xx(:)';yy(:)';zz(:)'; ones(size(zz(:)))']; 

    %%define affine transformation matrices 
T3d = [-0.02 0.02 1 -88 ; 
     -0.98 0 -0.02 130; 
     0  0.98 -0.02 -110; 
     0  0  0  1 ]; 
T2d = [-0.2 0  0  126; 
     0  0.2 -0.2 -131; 
     0  0  2  43 ; 
     0  0  0  1 ]; 

    %%transform A coordinates to world coordinates and world coordinates to B coordinates 
cooraInBref = T3d*inv(T2d)*coora; 
aslice = zeros(size(B)); 

    %% then nearest neighbor would go something like this (dont exactly know how to do this either): 
cooraInBround = round(cooraInBref); 
for idx = 1:length(coorb); 
    if cooraInBround(3,idx) == 0 
     aslice(cooraInBround(1,idx),cooraInBround(2,idx)) = ...;% dont know how to do this 
    end 
end 
    %% how would I implement sinc interpolation instead of rounding the transformed coordinates 

관련 질문 : 예를 들어

9,158,833,210

Interpolating 2D Matrix Data

scattered data interpolation

Python/PIL affine transformation

How do I rotate a 3D matrix by 90 degrees counterclockwise?

Resizing a 3D image (and resampling)

image transformations

,

chappjc anonsubmitter85와 케이프 코드에 의해 코멘트 지적 MATLAB에서 기능을 사용할 준비 : 코멘트와 링크 된 질문에 제안 scatteredInterpolant를 사용

http://mathworks.com/help/matlab/math/interpolating-scattered-data.html

http://mathworks.com/help/matlab/ref/griddata.html?refresh=true

My other SE question I use to get the affine matrix

거의 10 분이 걸렸고 모든 NaN과 슬라이스가 생겨서 다른 방법을 시도하고 있습니다.

+1

도움이 되셨습니까? http://www.mathworks.com/help/matlab/ref/griddata.html –

+1

'scatteredInterpolant'도 시도해 볼 수 있습니다. 그것은 sinc 보간법을 지원하지 않지만 linear가 충분하다는 것을 알 수 있습니다. – AnonSubmitter85

+1

'scatteredInterpolant' 사용 예제는 [this answer] (http://stackoverflow.com/a/21277035/2778484)를보십시오. – chappjc

답변

2

이제 다른 방법으로 시작합니다. 샘플로 2 차원 점을 가져온 다음 3d 볼륨으로 변환 한 다음 interp3을 사용하여 값을 계산합니다. 그것의 꽤 빠르며 잘 작동합니다. 이 코드는 단일 슬라이스를 가져 오는 경우에만 작동하지만 전체 변형 볼륨을 쉽게 적용 할 수 있다고 생각합니다. 나는 아직도 sinc 보간법을하는 방법을 모른다.

%% transformation from one image to the other 
Affine = inv(T2d)*T3d 

%% get coordinates for B 
sizb = size(B); clear xx;clear yy;clear zz; 
[xx,yy] = meshgrid(1:sizb(1),1:sizb(2)); 
zz = ones(size(xx)); 
coorb = [xx(:)';yy(:)';zz(:)'; ones(size(zz(:)))']; 

%% transformed coordinates 
coorb_t = Affine*coorb; 
idxX = reshape(coorb_t(:,1), sizb(1), sizb(2), 1); 
idxY = reshape(coorb_t(:,2), sizb(1), sizb(2), 1); 
idxZ = reshape(coorb_t(:,3), sizb(1), sizb(2), 1); 

%% interpolate 
Asliced = interp3(A, idxX, idxY, idxZ, 'cubic'); 

Z에 대해 0 또는 1을 사용해야하는지 확실하지 않습니다.

+1

좌표계에서 이미지 공간을 어떻게 처리합니까? 예를 들어 변환 행렬을 점에 적용하면 일부는 이미지 공간에서 벗어납니다. – JavaNullPointer

+0

interp3에서 처리하도록하되, 원하는 경우 외삽을 지정하십시오. http://nl.mathworks.com/help/matlab/ref/interp3.html?refresh=true#inputarg_extrapval – Leo