plot of differernt regions of specific area in a matrix

조회 수: 1 (최근 30일)
Hassan
Hassan 2011년 6월 23일
I wonder where in the follwing code i can add a condition which i can have the same plot but for regions (connected pixels) which have more than 10 pixels? I really apperciate your help.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2011년 6월 23일
Hi Hassan! Try this code:
L = bwlabel(m2 == 2);
lns = 1:max(L(:));
ln = regionprops(L, 'Area');
pm1 = find(ismember(L(:),lns([ln(:).Area]>=10)));
lidx = sortrows([L(pm1) pm1],1);
dplt = mat2cell([(1:size(lidx,1))' m1(lidx(:,2))],...
arrayfun(@(i1)nnz(lidx(:,1)==i1),unique(lidx(:,1))) ,ones(1,2));
n = size(dplt,1);
k=reshape('ymcrgbwk+o*.xv^>--------',[],3);
dplt2 = [dplt mat2cell([repmat(k,fix(n/8),1);k(1:rem(n,8),:)],ones(n,1),3)]';
plot(dplt2{:})
  댓글 수: 2
Hassan
Hassan 2011년 6월 24일
thanks a lot Anrei.
Hassan
Hassan 2011년 6월 24일
Another question. I want to make the same plot but for the mean value of each region. I wrote the following code which works. However, I want to show the color of each mean value with the same color was used in the above code for each region.
STATS = regionprops(L,m1,'MeanIntensity','Area','PixelValues');
n_stats = size(STATS,1);
mean_=zeros(n_stats,1);
[m_,n_] = find(cat(1,STATS.Area) >=10);
for i=1:n_stats
mean_(i)=STATS(i,:).MeanIntensity;
end
mean1=mean_(m_);
figure
plot(mean1)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Map Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by