Medical Image Processing: X and Y coordinates switched around after using find and ind2sub?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sam Donche
el 29 de Jul. de 2020
Respondida: Image Analyst
el 31 de Jul. de 2020
I am trying to extract the non-zero points from a mask made from a medical image. These points will be used for an orthogonal projection onto a plane.
I will describe my problem below.
The mask consists of a matrix of zeros (undesired pixels) and ones (desired pixels). The mask can be visualised with for example sliceViewer or orthosliceViewer. I show you orthosliceViewer in Figure 1. The attached .mat file contains one of these masks.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/338713/image.png)
You can observe that the middle of the mask is more or less
X = 239
Y = 207
Z = 85
In the next step I want to extract the coordinates of all the non-zero points (white on Figure 1). I use the following code:
index = find(mask);
[ori_x, ori_y, ori_z] = ind2sub([size(mask,1),size(mask,2),size(mask,3)], index);
This code makes sense to me. Next, I check the range of values in ori_x, ori_y, ori_z with the unique function.
This function show me that :
- X values vary between 199 and 215
- Y values vary between 233 and 248
- Z values vary between 77 and 93
When we compare these values to the "middle point of the mask" above. It seems that the Z value is fine, but the X and Y value seems to be switched.
I confirmed this suspision by extracting the centroid and bounding box of the mask using bwlabeln and regionprops3.
I know the quick fix would be to switch the X and Y value back, but I want to know what fundamental mistake I'm making. Can somebody help me?
Thanks in advance for your advice!
Sam
2 comentarios
Roger J
el 30 de Jul. de 2020
Sam,
This is a common misunderstanding.
Please see if this link answers your question:
Respuesta aceptada
Roger J
el 30 de Jul. de 2020
Sam,
This is a common misunderstanding.
Please see if this link answers your question:
If this is helpful, please mark as the answer.
0 comentarios
Más respuestas (1)
Image Analyst
el 31 de Jul. de 2020
ind2sub gives [row, column, slice], which is [y, x, z].
It does not give [ori_x, ori_y, ori_z] = ind2sub(...) like you had. Try
[ori_y, ori_x, ori_z] = ind2sub(....
0 comentarios
Ver también
Categorías
Más información sobre Image Processing Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!