line profile adding certain rows together

1 Ansicht (letzte 30 Tage)
Jason
Jason am 25 Okt. 2016
Beantwortet: Thorsten am 25 Okt. 2016
Hi. I have an image that I create a horizontal linescan through the centre (y co0rdinate = rMiddle)
I have also shown two red dotted lines that represent +/- 1 pixel. What I'm trying to do it centred around rMiddle, obtain a profile that sums the linescans together for not for +/-1 pixel but to extend +/- 3 pixels.
This is what I have so far but was wondering if their is a more elegant way.
yth_row=img(rMiddle,:)+img(rMiddle-1,:)+img(rMiddle+1,:)+img(rMiddle-2,:)+img(rMiddle+2,:)+img(rMiddle-3,:)+img(rMiddle+3,:);
Thanks Jason

Akzeptierte Antwort

Thorsten
Thorsten am 25 Okt. 2016
ind = [-3 -2 2 3] + rMiddle; % rows +/- 3 pixels from rMiddle, but without row rMiddle and the direct rows +/- 1 pixels above and below of rMiddle.
Y = sum(img(ind, :), 2); % sum across the second dimension, i.e., across columns

Weitere Antworten (0)

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by