How to set to zero specific elements of a 3D array?

3 views (last 30 days)
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?

Answers (1)

KALYAN ACHARJYA on 26 Oct 2022
Edited: KALYAN ACHARJYA on 26 Oct 2022
Here if the voxel element is equal to 4, 5 & 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
KALYAN ACHARJYA on 27 Oct 2022
Here tested with 2D, the logic works on all dimentional data array.

Sign in to comment.


Find more on Operators and Elementary Operations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by