MATLAB: How to obtain the values

image processing

Please could someone help me to get these two values….
1) The largest average intensity in the horizontal projection of an image (R1) and
2) The average intensity of zero from the top to bottom in the horizontal projection of an image (R2).
I'm working on Ultra-Sound images…. Please do reply….

Best Answer

Iorg = imread('./../../Downloads/r1r2.png');
I = rgb2gray(Iorg(58:242, 60:198, :));
m = mean(I, 2);
[notused R1] = max(m);
minthreshold = 0.3;
R2 = min(find(m < minthreshold));
subplot(2, 3, [1:3]), imshow(Iorg)
subplot(2,3,4), imshow(I)
subplot(2,3,5),
% plot vertical histogram
N = numel(m);
for i=1:N, line([0 m(i)], N-[i i]+1), end
axis tight
set(gca, 'PlotBoxAspectRatio', [1 size(I,1)/size(I, 2) 1])
set(gca, 'XTIck', [0:20:140])
set(gca, 'XAxisLocation', 'top')
set(gca, 'TickDir', 'out')
grid on
xlabel('Gray-level value')
ylabel('Image height')
subplot(2,3,6)
imshow(I)
line(xlim, [R1 R1], 'Color', 'y')
line(xlim, [R2 R2], 'Color', 'y')