How to calculate the pixel value segmentation

1 view (last 30 days)
Dear all,
I have code below. How to calculate the total counts in every volume segmentation P
All the image attached.
% For binary images (png format, each pixel just have value 1 and 0.)
clear all
close all
dataSetDir = fullfile('C:\Users\Akmal\Downloads\1.2.840.113619.\1.2.840.113619.');
imageDir = fullfile(dataSetDir,'gradieweigbwaftersegmentationpngTCEswari');
imds = imageDatastore(imageDir);
for i = 1:45
I = readimage(imds,i);
% binary
Is{i} = logical(I);
% For 3D images spect
myFolder = ('C:\Users\Akmal\Downloads\1.2.840.113619.\1.2.840.113619.\dcmeswariint16128x128');
filePattern = fullfile(myFolder, '*.dcm'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for K = 1 : length(theFiles)
baseFileName = theFiles(K).name;
fullFileName = fullfile(theFiles(K).folder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
% Now do whatever you want with this file name,
% such as reading it in as an image array with imread()
P(:,:,K) = dicomread(fullFileName);
P(:,:,K) = (P(:,:,K)) .* int16( Is{K} );
% P(:,:,K) = double(uint8(K).*uint8(Is{K}));

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by