필터 지우기
필터 지우기

Remove points in a 3D matrix that lie inside a 2D polygon on each layer

조회 수: 1 (최근 30일)
Cameron
Cameron 2024년 1월 31일
댓글: Cameron 2024년 2월 2일
I'm visualizing an MRI but am trying to remove a lot of artifacts that usually come in these images. I've implemented two solutions:
  1. use knnsearch to remove points too far away from their neighbors (i.e. floating out in the middle of nowhere) - works very well
  2. Have a user draw a polygon around remaining points from a topdown view (view 2) to remove the clusters of bad points from each layer.
The issue I'm running into is this: I can have a user create a polygon and get the points of the polygon with something like roi.Position, however I'm having trouble figuring out how to efficiently come through each Z layer of the matrix to remove the points within the polygon. Any ideas?
plot3(target_cluster(:,1,:),target_cluster(:,2,:))
roi = drawpolygon('Color','r');
My instinct is to run a for loop through each layer, but this seems inefficient. TIA
  댓글 수: 2
Matt J
Matt J 2024년 1월 31일
편집: Matt J 2024년 1월 31일
If the process is going to have an interactive step in each slice, why are you fretting that it be fast?
Cameron
Cameron 2024년 2월 1일
편집: Cameron 2024년 2월 2일
It won't be interactive per slice, I'm having the user draw a polygon from a top down view and effectively eliminate a vertical column group from the mri by adjusting the values of all points within that same polygon to 0 on every slice.

댓글을 달려면 로그인하십시오.

채택된 답변

Matt J
Matt J 2024년 2월 1일
and effectively eliminate a column from the mri by adjusting the values of all points within that same polygon to 0 on every slice.
If so, then once you've drawn the ROI, it would just be,
mriVolume=mriVolume.*(~roi.createMask);
  댓글 수: 3
Matt J
Matt J 2024년 2월 2일
편집: Matt J 2024년 2월 2일
Is this not what you want? You have an MRI image volume and you want to zero all pixels inside a polygon and repeat that for the same set of pixels in each slice. As you can see below, the result my answer gives is not 2D.
mriVolume=rand(3,3,3) %Fake mri volume
mriVolume =
mriVolume(:,:,1) = 0.9117 0.3054 0.8743 0.6790 0.5029 0.9291 0.4444 0.7229 0.0910 mriVolume(:,:,2) = 0.7140 0.6320 0.6661 0.6696 0.3753 0.0985 0.1696 0.9075 0.6249 mriVolume(:,:,3) = 0.4784 0.9112 0.7842 0.8221 0.8651 0.3624 0.3684 0.6878 0.9057
imshow(mriVolume(:,:,1))
roi=drawpolygon('Position', [0,0; 2,0; 0,3]*1.7);
mriVolume=mriVolume.*(~roi.createMask) %Delete pixels inside polygon in each slice
mriVolume =
mriVolume(:,:,1) = 0 0 0.8743 0 0 0.9291 0 0.7229 0.0910 mriVolume(:,:,2) = 0 0 0.6661 0 0 0.0985 0 0.9075 0.6249 mriVolume(:,:,3) = 0 0 0.7842 0 0 0.3624 0 0.6878 0.9057
Cameron
Cameron 2024년 2월 2일
Ah I see now, that's exactly what I'm looking for. Thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Biomedical Imaging에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by