I need to find standard deviation from labeled matrix

1 visualización (últimos 30 días)
Wannakarn Ketmorn
Wannakarn Ketmorn el 27 de Mzo. de 2021
Editada: DGM el 27 de Mzo. de 2021
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

Respuesta aceptada

DGM
DGM el 27 de Mzo. de 2021
Editada: DGM el 27 de Mzo. de 2021
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 comentarios
Image Analyst
Image Analyst el 27 de Mzo. de 2021
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
DGM el 27 de Mzo. de 2021
Editada: DGM el 27 de Mzo. de 2021
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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Image Segmentation and Analysis en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by