MATLAB Answers

alter image pixels intensities, gray scale image

3 views (last 30 days)
M on 30 Aug 2014
Commented: M on 30 Aug 2014
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
elseif (IMG(i,j,k)==1)
elseif (IMG(i,j,k)==0)
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

Answers (1)

Image Analyst
Image Analyst on 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?
M on 30 Aug 2014
Sorry for the misunderstanding I don't know specifically what value are CSF and BG are, yes they can be 0 or 1. I am running that on many images and every image has its color distribution. I am planning to use a vectorized code as soon as I solve the problem. BUT the problem now is not with the time the 3 loops take, its with why is not that simple code working as it is supposed to

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by