現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
Number of pixel, image outline and image processing
5 ビュー (過去 30 日間)
古いコメントを表示
Syahrul Niezam
2012 年 2 月 1 日
I'm still new in Matlab. I had segmented gray scale image into four regions like this.
I would like to calculate area/no. of pixel for each region within each human image. My idea is drawing outline of each human images and then calculate no. of pixel for white, light gray and dark gray regions in the image. Is there any idea to do that, or better idea? What i learnt and found only the method for binary image, not same with this one.
Thanks in advance.
採用された回答
Sean de Wolski
2012 年 2 月 1 日
doc bwconncomp
doc regionprops
doc bwarea
19 件のコメント
Syahrul Niezam
2012 年 2 月 1 日
Thank you.
I think, those are basic in calculating area etc. But it supposedly for binary image. Am I correct?
Anton Semechko
2012 年 2 月 1 日
Yep, regionprops is for binary images, but it also accepts labeled images as input, see documentation for bwlabel
Sean de Wolski
2012 年 2 月 1 日
regionprops will work on a label image (multiple levels of gray where each level is treated as a separate object). My idea for bewconncomp/bwarea is that you could regroup into binary objects - this may not be th ebest approach however and a direct call to regionprops would work.
Syahrul Niezam
2012 年 2 月 1 日
Thank you for your responds.
Do you mean I should apply bwconncomp on the image, and then regionprops?
Sean de Wolski
2012 年 2 月 1 日
It depends. Do you want each blob, regardless of the colors in it, to be treated as one object if the pixels are connected? If so, binarize and use bwconncomp and regionprops. If you want the different colors to be grouped together regardless of their location - regionprops directly.
Syahrul Niezam
2012 年 2 月 2 日
Is it possible to draw outline of each human, and the rest objects, and then calculate area/no. of pixel for white, light gray and dark gray area?
Syahrul Niezam
2012 年 2 月 2 日
I'm sorry, what I understand is bwconncomp is only for binary image. It's not working above image. Correct me if I'm wrong.
Walter Roberson
2012 年 2 月 2 日
Sean said "if so, binarize and use bwconncomp". You did not binarize.
binaryimg = logical(YourImage);
Syahrul Niezam
2012 年 2 月 2 日
I'm sorry for my mistake.
This is my code that I tried:
c = imread('image1_118.jpg');
a=double(c);
b = zeros(size(a));
b = uint8(a<90);
b(a >= 110) = 180;
b(a >= 150) = 200;
b(a >= 200) = 255;
subplot(121);figure(1);imshow(b);
y=logical(b);
C = bwconncomp(y);
CC = labelmatrix(C);
subplot(122);figure(1);imshow(y);
The bwconncomp part does not work well.
Walter Roberson
2012 年 2 月 2 日
Please be more specific about "does not work well".
You do not appear to be displaying C or CC.
Syahrul Niezam
2012 年 2 月 2 日
This is the code to binarize the image using logical. The result image is attached too.
http://i41.tinypic.com/33u3mrp.jpg
c = imread('image1_118.jpg');
a=double(c);
b = zeros(size(a));
b = uint8(a<90);
b(a >= 110) = 180;
b(a >= 150) = 200;
b(a >= 200) = 255;
subplot(221);figure(1);imshow(b);
y=logical(b);
%x=uint8(y);
%C = bwconncomp(y);
%CC = labelmatrix(C);
subplot(222);figure(1);imshow(y);
%subplot(223);figure(1);imshow(C);
However, the result of C did not come out.
Walter Roberson
2012 年 2 月 2 日
Your quantization is wrong. You assign the value 1 where a < 90, the value 0 where a was 90 to 109, the value 180 where a was 110 to 149, the value 200 where a was 150 to 199, and the value 255 where a was 200 to 255.
When you logical() this, the only parts that will come out 0 will be the parts where you had 0 in the matrix -- that is, the places where a was 90 to 109. Everything else in b is non-zero, including where a was < 90.
You need to re-think what value you want for a < 90 and for a from 90 to 109.
Syahrul Niezam
2012 年 2 月 2 日
Thank you for your responds.
I would like to assign the value 0 (black) for b where a<90, b=180 where 91<a<110; b=200 where 111<a<200; and b=255 (white) where 201<a<255.
If that possible, are logical, bwconncomp and labelmatrix can be applied?
Walter Roberson
2012 年 2 月 2 日
binmap = uint8([0 180 200 255]);
[counts, binidx] = histc(a(:), [0 90 110 200 256]);
b = reshape( binmap(binidx), size(a) );
And proceed.
Note: you did not indicate what should happen for a = 90 exactly, or a = 110 exactly, or a = 200 exactly or a = 255 exactly. The code I gave here uses 90 <= a < 110, 110 <= a < 200, 200 <= a < 256.
Syahrul Niezam
2012 年 2 月 2 日
Ops, i did mistake. It supposedly b=0 if a<=90; b=180 when 90<a=<110; b=200 when 110<a<=150; and b=255 when 150<a<=255.
That what's I desired to do so before calculating no. of pixel in same area and so forth.
Walter Roberson
2012 年 2 月 2 日
Okay in that case use
[counts, binidx] = histc(a(:), [0 91 111 151 256]);
Syahrul Niezam
2012 年 2 月 2 日
So, the whole code wlii be like this?
binmap = uint8([0 180 200 255]);
[counts, binidx] = histc(a(:), [0 91 111 151 256]);
b = reshape( binmap(binidx), size(a) );
subplot(221);figure(1);imshow(b);
y=logical(b);
x=uint8(y);
C = bwconncomp(y);
CC = labelmatrix(C);
subplot(222);figure(1);imshow(y);
subplot(223);figure(1);imshow(C);
Syahrul Niezam
2012 年 2 月 2 日
I would like to ask, is there any idea how to do labeling on non-binary image; like image above? What I understand, bwlabel is for binary (black and white) image only. Is it possible to 'recreate' or renovate itself?
Sean de Wolski
2012 年 2 月 2 日
A label image can be _ANY_ image if you choose to treat it as such. That is, you can treat equal intesities as objects.
その他の回答 (1 件)
Image Analyst
2012 年 2 月 1 日
See my image segmentation tutorial: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862. I do that exact thing, except for coins instead of humans.
8 件のコメント
Syahrul Niezam
2012 年 2 月 2 日
I had studied through the codes. However, it is for binary image. I am not counting the whole area of human image, but area of each white, light gray and dark gray regions within human image. (I hope my English is understandable).
Is it possible to draw outline of each human, and the rest objects, and then calculate area/no. of pixel for white, light gray and dark gray area?
Image Analyst
2012 年 2 月 2 日
It is not for a binary image. It uses a gray scale image, just like you do. There is a binary image that defines where you look in the gray scale image to compute areas and intensities, etc. but the original image is still gray scale and you should be able to adapt it very easily to your image. Very easily.
Syahrul Niezam
2012 年 2 月 2 日
I would like to ask, is there any idea how to do labeling on non-binary image; like image above? What I understand, bwlabel is for binary (black and white) image only. Is it possible to 'recreate' or renovate itself?
Image Analyst
2012 年 2 月 2 日
You can't do labeling on a non-binary image. It doesn't make sense. You have to have an image that separates your image into foreground and background, and that is a binary image. How can you do anything without deciding what is foreground and background? Tell me, does your image have a foreground? Of course it does.
Syahrul Niezam
2012 年 2 月 2 日
I want to apply labeling in above image, so that I can calculate no. of pixel for each levels; white, light gray, dark gray and black.
http://i44.tinypic.com/2nq8piw.jpg
However, I would like to calculate separately for each subject(human and non-human).
I really hope any code, basic or idea to do that.
Image Analyst
2012 年 2 月 2 日
First use bwareaopen() to get rid of small regions. Then say
binaryImage = yourImage >= 100 & yourImage <= 150; % Or whatever it needs for the range you're interested in.
labeledImage = bwlabel(binaryImage);
measurements = regionprops(labeledImage, 'area');
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)