alter image pixels intensities, gray scale image
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
So I was trying to make simple pixel alteration in an image by the following code
CSF = IMG(147,53,24);
BG = IMG(1,1,24);
for i=1:256
for j=1:256
for k=1:50
if(IMG(i,j,k)==CSF)
IMG(i,j,k)=1;
elseif(IMG(i,j,k)==BG)
IMG(i,j,k)=0;
elseif (IMG(i,j,k)==1)
IMG(i,j,k)=CSF;
elseif (IMG(i,j,k)==0)
IMG(i,j,k)=BG;
end
It is suppose to alter pixels with those specific intensities into the given ones. The BG part is working properly, but the CSF part won't alter properly and I don't know why
0 Kommentare
Antworten (1)
Image Analyst
am 30 Aug. 2014
What is "the CSF part"? CSF is mentioned on 3 lines. What is the value of CSF and BG? They're some scalar numbers. It should do the "if" for CSF for at least one voxel, and that is the one at (1,1,24). Have you tried stepping through with the debugger?
5 Kommentare
Image Analyst
am 30 Aug. 2014
M, I'm trying to see if this can be sped up by vectorizing but it depends on the values of CSF and BG. If they can be 0 or 1, we have a problem, and have to stay with your 3 loops. If they're not, we can vectorize and do this in a faster, more MATLAB-ish way. I don't care what GM is - you didn't even have that in your code, but you still haven't told me what the values of CSF and BG are, even after I've asked twice before (3 times now ). Can you at least tell me if they might ever take on the values of 0 or 1? Just trying to help here but you're not making it easy.
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!