Vectorize getting the intensity values from greyscale image
Show older comments
Hi, im trying to vectorize this piece of code to increase calculation speed, y1, y2, y3 is 1288x1 arrays with different y-indexpoints in a image matrix:
for xNr = 1:1288
intensity1(xNr) = image(y1(xNr), xNr); % Find intensity.
intensity2(xNr) = image(y2(xNr), xNr); % Find intensity.
intensity3(xNr) = image(y3(xNr), xNr); % Find intensity.
end
Then I get 3 arrays with dimension 1288x1 with intensity values.
And when I try to vectorize:
xNr = (1:1288);
intensity1 = image(y1, xNr); % Find intensity.
intensity2 = image(y2, xNr); % Find intensity.
intensity3 = image(y3, xNr); % Find intensity.
I get 3 arrays with dimension 1288x1288 which is wrong.
Can this be vectorized so I get the same result as in the for-loop?
Thanks in advance
2 Comments
KALYAN ACHARJYA
on 26 Jun 2019
Edited: KALYAN ACHARJYA
on 26 Jun 2019
Please clarify y1, y2 ?? or share the complete code
Aon
on 26 Jun 2019
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements 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!