How to sum up specific pixel intensities in image?

9 ビュー (過去 30 日間)
imageanalyz
imageanalyz 2016 年 11 月 21 日
コメント済み: Guillaume 2016 年 11 月 21 日
I have a question about image pixel intensity.I want to sum up specific pixel intensities in an image.For example intensitylevel>120. How can I do this?

回答 (2 件)

Joseph Cheng
Joseph Cheng 2016 年 11 月 21 日
you can use logical ">" to find the values greater than 120
example = magic(10);
ind=find(example>50);
sumintent = sum(example(ind));
  3 件のコメント
Joseph Cheng
Joseph Cheng 2016 年 11 月 21 日
I tried to make it simple based of the level of the question. You don't need the double sum with the find as it'll return a 1xN.
Guillaume
Guillaume 2016 年 11 月 21 日
True. However, you'll find a lot of beginner use find when it's not needed. In the end, the simplest is probably:
sumintent = sum(example(example(:) > threshold));

サインインしてコメントする。


Changoleon
Changoleon 2016 年 11 月 21 日
Do you want to get rid of the intensities less than 120? so that you end up with the pixels intensities over 120? If this is the case you can binarize your image as following:
a = double(imread('cameraman.tif'));
figure; imagesc(a); colormap gray
b = a>120;
figure; imagesc(b); colormap gray
In case you want the number of pixels who carry the intensity of 1 in your binirized image (image b in example above) you can do the following:
c = sum(sum(b)); %this is the numbper of pixels that have the value of 1 in the entire binary image

カテゴリ

Help Center および File ExchangeModify Image Colors についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by