I need to find standard deviation from labeled matrix
조회 수: 2 (최근 30일)
이전 댓글 표시
My project need to find homogeneity from each cell from image so I decided to use SD for each cell
but I already try std(A) but it doesn't work I try meanintensity in regionprops but I don't know what to do next
do I have anyway to get SD from each labelmatrix
clear
clc
close all
IMG = imread('Cal-IR-MP-3.jpg');
blue = IMG(:,:,3);
th = graythresh(blue);
bw = imbinarize(blue,th);
bw = imclearborder(bw,8);
seD = strel('disk',3);
bw = imopen(bw,seD);
CC = bwconncomp(bw, 8);
L = labelmatrix(CC);
xx = [];
a = 1;
LL1 = L;
for i = 1:CC.NumObjects
LL = L;
if length(CC.PixelIdxList{i})<1000
LL(LL==i) = 0;
LL1(LL1==i) = 0;
else
LL(LL ~= i) = 0;
LL(LL == i)= 1;
xx(a,1) = i;
stats = regionprops(LL,blue,'MeanIntensity');
xx(a,2) = stats.MeanIntensity;
s = std2(i);
a = a+1;
end
end
댓글 수: 0
채택된 답변
DGM
2021년 3월 27일
편집: DGM
2021년 3월 27일
If what you're trying to do is get the standard deviation of the regions specified by the label matrix, try this.
clear variables; clc; close all
IMG = imread('sources/blacklight2.jpg'); % i used my own test image
blue = IMG(:,:,3);
th = graythresh(blue);
bw = imbinarize(blue,th);
bw = imclearborder(bw,8);
seD = strel('disk',3);
bw = imopen(bw,seD);
CC = bwconncomp(bw, 8);
L = labelmatrix(CC);
xx = [];
a = 1;
LL1 = L;
for i = 1:CC.NumObjects
% only evaluate groups above a certain size
if length(CC.PixelIdxList{i})<1000
% idk what you're doing with LL1
% i'll assume this is for something else
% LL was being rewritten and unused, so I removed it
LL1(LL1==i) = 0;
else
roidata=double(blue(L==i)); % extract the ROI
xx(a,:) = [i std(roidata(:))]; % write to output array
a = a+1;
end
end
xx
If LL1 isn't used for anything outside this scope, then it simplifies to
clear variables; clc; close all
IMG = imread('sources/blacklight2.jpg');
blue = IMG(:,:,3);
th = graythresh(blue);
bw = imbinarize(blue,th);
bw = imclearborder(bw,8);
seD = strel('disk',3);
bw = imopen(bw,seD);
CC = bwconncomp(bw, 8);
L = labelmatrix(CC);
xx = [];
a = 1;
for i = 1:CC.NumObjects
if length(CC.PixelIdxList{i})>=1000
roidata=double(blue(L==i));
xx(a,:) = [i std(roidata(:))];
a = a+1;
end
end
xx
idk if that helps
댓글 수: 2
Image Analyst
2021년 3월 27일
You can use bwareafilt() or bwareaopen() in advance of the labeling to avoid having to check blobs less than 1000 pixels inside the loop.
DGM
2021년 3월 27일
편집: DGM
2021년 3월 27일
I was kind of assuming that maybe those small groups might be used for something else. Otherwise, yeah. That would clean things up a bit and potentially save some time as well.
IMG = imread('sources/blacklight2.jpg');
blue = IMG(:,:,3);
th = graythresh(blue);
bw = imbinarize(blue,th);
bw = imclearborder(bw,8);
seD = strel('disk',3);
bw = imopen(bw,seD); % idk that this is needed if using bwareaopen
bw = bwareaopen(bw,1000,8);
CC = bwconncomp(bw, 8);
L = labelmatrix(CC);
xx = zeros([CC.NumObjects 2]);
for i = 1:CC.NumObjects
roidata=double(blue(L==i));
xx(i,:) = [i std(roidata(:))];
end
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!