How to find neighbor voxels of a given voxel?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Sandhiya Prakash
am 15 Mär. 2017
Kommentiert: Makis
am 25 Nov. 2020
Hi! I am working with 3D MRI image of size(164x187x145). For a given voxel i need to consider 26 neighbouring 3x3x3 patch.(now 27 scalar values)Then consider all 26 neighbouring conventional 3x3x3 patches and compute average intensity for all these neighbouring patches.(So totally i have 53 scalar intensity values).How to perform this? Anyone who knows Plz reply !! code that i referred is as follows
function[IndexNeighbours] = findNeighbours(Index,MatrixSize)
%%**************************************************************************
% Module name: findNeighbours.m
% Version number: 1
% Revision number: 00
% Revision date: 10-2013
2013 (C) Copyright by Patrick Granton Maastro Clinic
% Outputs:
% IndexNeighbours = The index positions of valid voxels
% Usage: [IndexNeighbours] = findNeighbours(33014,[400 400 400])
Description:
%*************************************************************************
% References:
%
%*************************************************************************
%%Revision History
% %%*************************************************************************
%1
Base = [+1 +1 0 ...
%2
+1 -1 0 ...
%3
+1 +1 +1; ...
%4
+1 0 +1; ...
%5
+1 -1 +1; ...
%6
+1 +1 -1; ...
%7
+1 0 -1; ...
%8
+1 -1 -1; ...
%9
+1 0 0 ...
%10
0 +1 0 ...
%11
0 -1 0 ...
%12
0 +1 +1; ...
%13
0 0 +1; ...
%14
0 -1 +1; ...
%15
0 +1 -1; ...
%16
0 0 -1; ...
%17
0 -1 -1; ...
%18
-1 +1 0 ...
%19
-1 -1 0 ...
%20
-1 +1 +1; ...
%21
-1 0 +1; ...
%22
-1 -1 +1; ...
%23
-1 +1 -1; ...
%24
-1 0 -1; ...
%25
-1 -1 -1; ...
%26
-1 0 0];
[I J K] = ind2sub([MatrixSize],Index);
neighbours = Base+repmat([I J K],[26 1]);
valid_neighbours = (1 - sum(neighbours(1:26,:)<=0,2));
valid_neighbours_Indices = find(valid_neighbours==1);
IndexNeighbours = sub2ind([MatrixSize],[neighbours(valid_neighbours_Indices,1)],[neighbours(valid_neighbours_Indices,2)],[neighbours(valid_neighbours_Indices,3)]);
end
My doubt is what i must give for matrixsize and index if I am using 164*197*145 3D matrix?
Thanks in advance!
0 Kommentare
Akzeptierte Antwort
KSSV
am 15 Mär. 2017
You may use knnsearch to get the nearest neighbors. Read about knnsearch
3 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu MRI finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!