centroid for each slice along one axis in a .nrrd file
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hi All
I have some medical images, saved as .nrrd files. (segmented)
I would like to calculate the centroid for each slice along a single axis.
Then create a line of best fit for this.
Any suggestions for this please,(I am very much a beginner in matlab and not of engineering background.)
Thanks heaps
채택된 답변
Ergin Sezgin
2023년 3월 28일
Hey,
You can isolate the layers, binarize them with imbinarize function, manipulate the regions by morphology if necessary, and then get the region properties by regionprops function. This will yield the centroid data for each region. Then you can extract centroids into an array and fit a line in 3D space using these values.
Good luck.
댓글 수: 6
Thanks Ergin,
It seems that imbinarize works with .pngs?
I have segmentations , saved as .nrrd.
Its a 3D structure,
I am not able to convert them to 2D slices of pngs
I can use nrrdread to read the nrrd file, which generates a 3D volume
Then it think it gives me a single value for the enitre bounding box I think.
What I am looking for is slice by slice centroids for the partcular volume. Any thoughts pls
Thanks
Hello again,
imbinarize works with 2D and 3D grayscale images.
After importing .nrrd data into your workspace, I presume you will see a 3 dimensional single class array. It represents consecutive 2D slices of volume data. You can access each slice and save them into different variables by indexing such as slice_1 = nrrdData(:,:,1), slice_2 = nrrdData(:,:,2). A loop would be a better way to extract and process these slices. After you get slices, you can perform binarization and morphological processes which will enable you to have centroids data.
Is it possible for you to save the data you get after importing by nrrdread function, into a .mat file and share here?
Regards
Thanks I think , slice function extarct the entire bounding box,
Not sure what I am doing sorry,
Shared the mat file
Hello,
You can use the following code to access and examine each layer after your import the .nrrd data. centroidsArray should yield the output you want. Try it yourself and please let me know the outcome.
centroidsArray = [];
for i=1:1:size(V,3)
currentLayer = V(:,:,i);
currentLayer = logical(currentLayer);
regionProperties = regionprops("table", currentLayer, "Centroid");
if ~isempty(regionProperties)
if height(regionProperties) > 1
for j=1:height(regionProperties)
rowData = [regionProperties.Centroid(j,:), i];
centroidsArray = [centroidsArray; rowData];
end
else
rowData = [regionProperties.Centroid(1,:), i];
end
centroidsArray = [centroidsArray; rowData];
end
end
figure
scatter3(centroidsArray(:,1),...
centroidsArray(:,2),...
centroidsArray(:,3), '.')
axis equal
grid on
You can then fit a line using centroids.
Good luck
Perfect @Ergin Sezgin
Thanks so much,
This worked,
Now my problem is converting this to mm/ world coordinates rather than pixels.
I get the line I want but I cant align it on my STL model created with the same exact .nrrd file. I think the problem is that the numbers in the centroid array are in pixels/voxels.
Please let me know if you a way for this
I am currently reading and trying, will update if I can work this out.
Hey Mel,
I'm glad that it worked.
Normally, I use calibration plates and tools such as a checkerboard plates to compute intrinsic parameters which enable me to get distortion free images. Knowing the real size of checkerboard squares and getting an image of the board, it is possible to get an analytical relation between real world dimensions and pixels. This is useful for 2D data. For the third dimension along Z axis, you need some kind of encoder. You can assume every layer has an equal distance between each other or you can get real, precise distances between layers from the hardware you use to get .nrrd data.
I hope this helps
Good luck
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
