How to set to zero specific elements of a 3D array?
15 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(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 个评论
KALYAN ACHARJYA
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
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!