How to calculate the summation pixel counts seperately.

5 ビュー (過去 30 日間)
mohd akmal masud
mohd akmal masud 2021 年 11 月 12 日
回答済み: Image Analyst 2021 年 11 月 13 日
Hi all, I have 146 slices images. That is dicom images. every pixel have their own counts (index number) like picture below. I used this below command to read it first.
%% Read main set data
clc
clear all
[spect map]=dicomread('I131256x256 10N1.dcm');
info = dicominfo('I131256x256 10N1.dcm');
%gp=info.SliceThickness;
spect=(squeeze(spect));%smooth3
aa=size(spect);aa=aa(3);
imshow3D(spect)
Then I used used command below to do some segmentation for the 4 sphere blob. The image binary as below.
%% NI KALAU VOLUME1 en amin prepapre 10:1
% BCKG 69 MAX 381 bckgratio=5.52
seedR1 = 110; seedC1 = 149; seedP2 = 88;
W1 = graydiffweight(spect, seedC1, seedR1, seedP2 , 'GrayDifferenceCutoff', 1000000);
thresh1 = 0.004478;
[BW1, D1] = imsegfmm(W1, seedC1, seedR1, seedP2, thresh1);
% figure, imshow3D(BW1)
T1 = regionprops('table', BW1,'Area','Centroid')
% NI KALAU VOLUME2 en amin prepapre 10:1
% BCKG 69 MAX 221 bckgratio=3.20
seedR2 = 134; seedC2 = 148; seedP2 = 88;
W2 = graydiffweight(spect, seedC2, seedR2, seedP2 , 'GrayDifferenceCutoff', 1000000);
thresh2 = 0.001437;
[BW2, D2] = imsegfmm(W2, seedC2, seedR2, seedP2, thresh2);
% figure, imshow3D(BW2)
T2 = regionprops('table', BW2,'Area','Centroid')
% NI KALAU VOLUME3 en amin prepapre 10:1
% BCKG 69 MAX 143 bckgratio=2.07
seedR3 = 146; seedC3 = 127; seedP3 = 88;
W3 = graydiffweight(spect, seedC3, seedR3, seedP3 , 'GrayDifferenceCutoff', 1000000);
thresh3 = 0.000326;
[BW3, D3] = imsegfmm(W3, seedC3, seedR3, seedP3, thresh3);
% figure, imshow3D(BW3)
T3 = regionprops('table', BW3,'Area','Centroid')
% NI KALAU VOLUME4 en amin prepapre 10:1
% BCKG 69 MAX 109 bckgratio=1.57
seedR4 = 134; seedC4 = 107; seedP4 = 88;
W4 = graydiffweight(spect, seedC4, seedR4, seedP4 , 'GrayDifferenceCutoff', 1000000);
thresh4 = 0.000092;
[BW4, D4] = imsegfmm(W4, seedC4, seedR4, seedP4, thresh4);
% figure, imshow3D(BW4)
T4 = regionprops('table', BW4,'Area','Centroid')
allBW = BW1 | BW2 | BW3 | BW4 ;
imshow3D(allBW);
My problem is how to get the total counts for each blob?
I try this one but it summation of all counts pixel for all blob
>> totalcountseachblob = sum(spect(allBW==1))
totalcountseachblob =
722358
Anyone can help me?

採用された回答

yanqi liu
yanqi liu 2021 年 11 月 13 日
sir,may be use
save allBW.mat allBW
and upload this mat file, so we can do some code to analysis
  5 件のコメント
mohd akmal masud
mohd akmal masud 2021 年 11 月 13 日
its work..tq so much sir..

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2021 年 11 月 13 日
@mohd akmal masud you have the image of all 4 blobs, allBW, so to get the area of each one you simply need to do
totalcountseachblob = nnz(allBW);
That is the total number of pixels in the binary image. If you want the "integrated gray values" from the original gray scale image, you can use that as a mask
pixelValues = spect(allBW);
igv = sum(pixelValues);
Also you have the "total counts for each blob" if you just run regionprops() on your allBW image:
allT = regionprops('table', allBW,'Area','Centroid') % The individual areas of each blob in a table.
allAreas = allT.Area; % The individual areas of each blob in a double vector.

Community Treasure Hunt

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

Start Hunting!

Translated by