Discarding certain centroids found using regionprops

8 ビュー (過去 30 日間)
NS
NS 2011 年 5 月 19 日
編集済み: Aaron Greenbaum 2016 年 7 月 22 日
Hi, I work with time sequence images. I process and threshold these images to get a black image with some scattered white spots. I want to track these white spots as a function of time and I want to use their centroids to do so.
I am using the functions 'bwlabel' and 'regionprops' to find the centroid and area of the white spots. The problem I am facing is that regionprops also computes the centroids and areas of certain small white specks that are in the black region of my image. I see that all of these points have a unit area. These specks may be just noise.
Hence I was wondering if someone could tell me what function I could use to remove these unwanted points. I know their areas and their position in the regionprops matrix.
Thanks
NS
If 'I' is my processed double image, my code is as follows:
L=bwlabel(I);
s=regionprops(L,'Centroid','Area');

採用された回答

Sean de Wolski
Sean de Wolski 2011 年 5 月 19 日
What do you mean it computes the centroid parts in a black area? There's no way that it does that.
It's possible the centroid of a blob isn't in the blob. But it's definitely not calculating centroids for the background. If you think of a blob in the shape of "U", the centroid will not lie in on the U.
If you want to keep only centroids that occur in the area of a blob, that's easily possible.
EDIT Per comment/clarification:
I would just use bwareaopen on your logical image to remove small blobs.
I = bwareaopen(I,10); %all objects with fewer than 10px gone.
  2 件のコメント
NS
NS 2011 年 5 月 19 日
You are correct. Those unwanted centroids are for tiny white specks that are still there in my thresholded image. I think these specks are just noise. So is there any way I could discard those centroids?
NS
NS 2011 年 5 月 19 日
It worked. bwarea removed the unwanted blobs. Thanks Sean. :)

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

その他の回答 (1 件)

Aaron Greenbaum
Aaron Greenbaum 2016 年 7 月 22 日
編集済み: Aaron Greenbaum 2016 年 7 月 22 日
Hello NS, I'm actually doing something that sounds pretty similar. It sounds like these unwanted centroids probably have smaller area than your desired centroids. I remove all of the points that are below a certain minimum area using a logical vector.
smoothimg=filter2((ones(2)/2.^2),inimg); %Smooth image
threshimg=smoothimg>thres; %apply threshold
stats = regionprops(threshimg,smoothimg, 'Area', 'WeightedCentroid');
rel_peaks_vec=[stats.Area]>=minarea; %makes logical vector for points greater than minarea as true
cents= [stats(rel_peaks_vec).WeightedCentroid]'; %appostrophe causes a transpose of the matrix
Maybe this can give you some ideas. Just realized this was 5 years old. My bad haha.

カテゴリ

Help Center および File ExchangeImage Segmentation and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by