How to set to zero specific elements of a 3D array?
이전 댓글 표시
I have a 3D image (array). I want to set to zero all the voxels with numbers 4, 5, 12 and 50-56. Does anyone know how to do this?
답변 (1개)
KALYAN ACHARJYA
2022년 10월 26일
편집: KALYAN ACHARJYA
2022년 10월 26일
Here if the voxel element is equal to 4, 5 & 50..so on. , all such voxels element will be replaced by 0 (Zero)
data= % #3D Array Element/Image with 3 planes
data(data==4 | data==5 | data==50)=0 %Set the condition accordingly
댓글 수: 5
Demy
2022년 10월 27일
KALYAN ACHARJYA
2022년 10월 27일
편집: KALYAN ACHARJYA
2022년 10월 27일
No, if you refering indices (e.g., 3,4,5)
data(3,4,5)=1
If you refering voxel value (data value), then
data(data~=3 & data~=4 & data~=5)=0
data(data~=0)=1
You can do it in single line too.
Demy
2022년 10월 27일
data=randi([0,60],[10 10])
%..............^ test example only, you can check with 208
data(data~=52 & data~=53)=0
data(data~=0)=1
KALYAN ACHARJYA
2022년 10월 27일
Here tested with 2D, the logic works on all dimentional data array.
카테고리
도움말 센터 및 File Exchange에서 Geometric Transformation and Image Registration에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!