Computing the sum of each column in an image

Hi i want to find out the sum of individual columns in an image and draw a plot indicating the number of pixels in each column(A density chart).Here is my code. Please help me further.
CODE:
clc;clear all,close all;
newimage=imread('NEW1.jpg');
count=find(newimage<1);
disp(count);
sum1=sum(newimage');
display(sum1);
OUTPUT:
sum1 =
Columns 1 through 5
69646 69446 18233 68154 57611
Columns 6 through 10
45726 36549 54894 20902 3878
Columns 11 through 15
45726 .......
BUT I WANT MY OUTPUT TO BE AS
4512(say)[sum for the first column] 4561[for the second column] and so on....
HOW TO GET IT??? PLEASE HELP

댓글 수: 6

Walter Roberson
Walter Roberson 2011년 1월 22일
This question appears to be a duplicate (with some rephrasing) of the posters earlier question http://www.mathworks.com/matlabcentral/answers/255-creating-a-plot-of-intensity-of-pixels-across-an-image-using-matlab
Niranjan
Niranjan 2011년 1월 23일
ya its me who asked it earlier,but now in detail :)
Kenneth Eaton
Kenneth Eaton 2011년 1월 23일
Niranjan, you should be able to edit the original question to add more detail, which would be better than reasking it.
Niranjan
Niranjan 2011년 1월 23일
bar(avg(newimage<1)) when I use the above code I get a bar . But I need a bar with the number of black pixels on the y axis. Can you help?
This is what I am exactly in need of. Please have a look.
http://picasaweb.google.com/lh/photo/uzVPD9_OcmXMtPGw4m0jyJOzMXS1UfqXPDW9N1lFu0w?feat=directlink
Walter Roberson
Walter Roberson 2011년 5월 13일
duplicates http://www.mathworks.com/matlabcentral/answers/255-creating-a-plot-of-intensity-of-pixels-across-an-image-using-matlab
Sampath Kumar
Sampath Kumar 2017년 10월 17일
bar(mean(~im))

댓글을 달려면 로그인하십시오.

 채택된 답변

Walter Roberson
Walter Roberson 2011년 1월 22일

0 개 추천

The number of pixels in each column of an image is a constant. If you only want to count the number of pixels below a certain value, then:
bar(mean(newimage<TheValue)))

댓글 수: 7

Niranjan
Niranjan 2011년 1월 23일
ya the number of pixels is the same, I was wrong with the question . I mean to count the number of black pixels alone.
Niranjan
Niranjan 2011년 1월 23일
bar(avg(newimage<1)) when I use the above code I get a bar . But I need a bar with the number of black pixels on the y axis. Can you help?
This is what I am exactly in need of. Please have a look.
http://picasaweb.google.com/lh/photo/uzVPD9_OcmXMtPGw4m0jyJOzMXS1UfqXPDW9N1lFu0w?feat=directlink
Walter Roberson
Walter Roberson 2011년 1월 23일
In that case, simply
plot(sum(newimage<TheValue))
You have been asking for the *density* and to my mind, a *count* is not a density.
Niranjan
Niranjan 2011년 1월 24일
Thanks for your reply Roberson and can you tell me how to find the distance between the least two minimum positions in this plot?
Niranjan
Niranjan 2011년 1월 24일
Please have a look at this.Help me with this
http://picasaweb.google.com/lh/photo/4Rb9z8TNa1PcNO-Jjs3ydpOzMXS1UfqXPDW9N1lFu0w?feat=directlink
Walter Roberson
Walter Roberson 2011년 1월 24일
You don't need to plot to find that.
t = sum(newimage<TheValue);
[ts, tidx] = sort(t);
min2dist = abs(tidx(2) - tidx(1));
Niranjan
Niranjan 2011년 1월 25일
Thanks a lot :)

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Paulo Silva
Paulo Silva 2011년 1월 22일

0 개 추천

[X,map] = imread('trees.tif'); %example of an image
col=1:numel(X(1,:)); %create a column vector for the next code line
Count(col)=sum(X(:,col)); %is this what you want?

댓글 수: 1

Niranjan
Niranjan 2011년 1월 23일
bar(avg(newimage<1)) when I use the above code I get a bar . But I need a bar with the number of black pixels on the y axis. Can you help?
This is what I am exactly in need of. Please have a look.
http://picasaweb.google.com/lh/photo/uzVPD9_OcmXMtPGw4m0jyJOzMXS1UfqXPDW9N1lFu0w?feat=directlink

댓글을 달려면 로그인하십시오.

JEBA CHRISTILDA
JEBA CHRISTILDA 2016년 8월 26일

0 개 추천

Hi i want to create a graph for each blocks of binned image. it was an medical image can anybody please help me.

댓글 수: 1

Please create a new Question for that.
In the new Question, describe what kind of graph you want to create, and indicate whether you need assistance with the dividing into blocks or only with the graphing.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Images에 대해 자세히 알아보기

제품

질문:

2011년 1월 22일

댓글:

2017년 10월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by