Azzera filtri
Azzera filtri

How to resolve the error of looping

3 visualizzazioni (ultimi 30 giorni)
mohd akmal masud
mohd akmal masud il 18 Nov 2023
Commentato: Peter Perkins il 20 Nov 2023
Dear All,
I wrote some script looping to determine the thresh value for certain volume (26.67). But I got error like below. The set imageas data set as attached.
Can help me?
%% I131 10:1 graycutoff 100000 latest GUNA FWHM
clc
clear all
close all
[spect map]=dicomread('I-131sphere10nisbah1.dcm');
info = dicominfo('I-131sphere10nisbah1.dcm');
%gp=info.SliceThickness;
spect=(squeeze(spect));%smooth3
aa=size(spect);aa=aa(3);
imshow3D(spect)
figure, imtool3D(spect)
seedR1 = 58; seedC1 = 76; seedP1 = 45;
W = graydiffweight(spect, seedC1, seedR1, seedP1, 'GrayDifferenceCutoff', 1000000000);
for thresh =0.0001:0.0001:0.9999;
[BW, D] = imsegfmm (W, seedC1, seedR1, seedP1, thresh);
T = regionprops ('table', BW,'Area','Centroid');
if T(1)==26.67; %want to know thresh value for volume 26.67
gray_weight = thresh;
volume = T(1)
break
end
end
Error using ()
Subscripting into a table using one subscript (as in t(i)) is not supported. Specify a row
subscript and a variable subscript, as in t(rows,vars). To select variables, use t(:,i) or for
one variable t.(i). To select rows, use t(i,:).

Risposte (1)

Image Analyst
Image Analyst il 18 Nov 2023
T is a table with the first column being the blob area and the second column being (x,y) of the centroid. Row 1 is for blob %1, row 2 is for blob #2, and so on. T(1) doesn't make sense because T, when using numerical indexes, is a 2-D array, not a 1-D array. So if you wanted the area of blob #2, you'd reference it with 2 indexes as T{2, 1} (with braces) or as T.Area(2) (equivalent but using the variable name of the column). I don't know how many blobs you will have in your binary image.
And you should not use regionprops for volumes, you should use the 3-D version regionprops3 to get volume of blobs.
Also you should not use fractional numbers for the area or volume since regionprops returns them as integer values (the discrete number of pixels or voxels), not as floating point areas or volumes. Even if it were, you should not compare floating point numbers with ==, you should use ismembertol. See the FAQ: https://matlab.fandom.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_(or_similar)_not_equal_to_zero?
  6 Commenti
Walter Roberson
Walter Roberson il 19 Nov 2023
you posted this as s new question and I answered there
Peter Perkins
Peter Perkins il 20 Nov 2023
You might find T.Area(1), or even T{1,"Area"}, easier to read than T{1,1}.

Accedi per commentare.

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by