Altering CT Volume voxel values in Matlab

1 visualizzazione (ultimi 30 giorni)
Noha Asas
Noha Asas il 14 Lug 2014
Commentato: Ben11 il 24 Lug 2014
I am trying to alter some voxel values in Matlab.
I am using the following code:
for p=1:100
Vol(Vol(:,:,p) > 0) = 65535; %altering voxel values in the volume to 65535 if value > 0.
end
Unfortunately, I find all the values being altered, as if the condition is not working, although if i write Vol(Vol(:,:,1)>0)= 65535 immediately in the command line it works perfectly.
Any clue where the error is??

Risposta accettata

Ben11
Ben11 il 14 Lug 2014
Modificato: Ben11 il 14 Lug 2014
It looks like when you use this line:
Vol(Vol(:,:,p) > 0) = 65535
you are in fact referring to a 2D matrix corresponding to a single channel from an image instead of a 3-channel image from your volume. I think it would save you trouble if you used this:
Vol(Vol > 0) = 65535;
instead of your for-loop, since you would then replace all the pixel values greater than 0 with 65535.
EDIT:
I just saw that you asked this question on Stack Overflow, good idea by the way, and that Ray provided a very thorough explanation! Anyhow I hope it is clearer for you now :)
  4 Commenti
Noha Asas
Noha Asas il 23 Lug 2014
Many thanks again....that's very helpful :). Sorry for late response....was away from internet connection.
Ben11
Ben11 il 24 Lug 2014
No problem! Glad I could help :)

Accedi per commentare.

Più risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by