how to obtain the values

1 view (last 30 days)
Elysi Cochin
Elysi Cochin on 14 Jan 2013
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....

Accepted Answer

Thorsten
Thorsten on 16 Jan 2013
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')
  1 Comment
Elysi Cochin
Elysi Cochin on 17 Jan 2013
thank u sir.... thank u so much....

Sign in to comment.

More Answers (2)

Jan
Jan on 14 Jan 2013
  1. What is the "horizontal projection of the image". The more precise the question, the more correct the answer ;-)
  2. Isn't the average intensity of zero equal to zero? And does "from the top to bottom" changes anything for this trivial fact?
Please post more details.
  1 Comment
Elysi Cochin
Elysi Cochin on 14 Jan 2013
Edited: Elysi Cochin on 14 Jan 2013
sir i have uploaded the image of what i want... i want to obtain those values, from that image those marked as R1 and R2..... please do reply....
the link is...
sir i want to obtain values R1 and R2 and display the region between R1 and R2.... please do reply sir....

Sign in to comment.


Image Analyst
Image Analyst on 14 Jan 2013
Use the sum or the mean function
verticalProfile = sum(yourArray(:,column1:column2), 1);
horizontalProfile = sum(yourArray(row1:row2, :), 2);
  2 Comments
Elysi Cochin
Elysi Cochin on 16 Jan 2013
Edited: Elysi Cochin on 16 Jan 2013
sir what is yourArray,column1 column2,row1,row2... sir did u see the above link sir... in that, is it i need to compute the histogram of the image, to get those to values... if so how to get the highest value and zero point value from the histogram.... sir can u please show me with respect to that link sir....
Image Analyst
Image Analyst on 16 Jan 2013
Edited: Image Analyst on 16 Jan 2013
yourArray is the name of your array. What do you call the name of your image array variable? row1 is your R1, isn't it? And my row2 is what you call R2, don't you think? In general when you do something like yourArray(row1:row2, :), that's taking just the part of the yourArray image between row1 and row2 inclusive - this is standard basic MATLAB terminology. It gets a submatrix portion of the full size matrix. Does that explain it better?
Regarding histogram, you have not mentioned histogram before. You do realize that a histogram and a profile are two completely different things don't you? If you want the max of the vertical profile, you can do
maxIndexes = find(verticalProfile == max(verticalProfile));
maxValue = verticalProfile(maxIndexes(1));
Because there may be more than one location of the max (several elements have the same max value), that's why you don't want to use the max() function like some people may suggest. max() only gives you the first max it encounters.
If you really do want a histogram then you have to do
[pixelCounts, grayLevels] = imhist(yourArray(R1:r2,:),256);
Then to find the max of the counts (which gray level bin has the most counts (pixels)):
maxIndexes = find(pixelCounts== max(pixelCounts));
modeGrayLevel = grayLevels(maxIndexes(1));
To find the highest gray level
maxGL = max(max(yourArray(R1:r2,:)));

Sign in to comment.

Categories

Find more on Images 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!