how to write looping for certain area determine
3 ビュー (過去 30 日間)
古いコメントを表示
mohd akmal masud
2023 年 11 月 19 日
コメント済み: Walter Roberson
2023 年 11 月 21 日
Dear all,
I wrote some script looping to determine the thresh value for certain Area (267). But I got error like below. The set imageas data set as attached.
Actually, my original script is like below:
seedR1 = 58; seedC1 = 76; seedP1 = 45;
W = graydiffweight(spect, seedC1, seedR1, seedP1, 'GrayDifferenceCutoff', 1000000000);
thresh =0.0001;
[BW, D] = imsegfmm (W, seedC1, seedR1, seedP1, thresh);
T = regionprops('table', BW,'Area','Centroid')
Area Centroid
____ __________________________
12 75.833 58.167 44.5
Then I have to change the thresh (try and error) until I got the Area is 267.
But I want to do something like looping or iteration, which is I set the Area is 267. Then wrote the script like below:
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,1}==267
gray_weight = thresh;
volume = T{1,1};
end
end
Can anyone help me?
0 件のコメント
採用された回答
Walter Roberson
2023 年 11 月 19 日
移動済み: Walter Roberson
2023 年 11 月 19 日
Have you considered using fzero or fsolve? Those could use slope information to zoom in on the appropriate thresh
The objective would be something along the lines of
accept parameter Th. Use it with the segmm. Regionprops to get the area. Return area minus 267.
fzero or fsolve would then supply trial thresholds and would search for one that made the function zero. The function is area minus 267 so a zero for the difference would be equivalent to having searched for the threshold that gave an area of 267
9 件のコメント
Walter Roberson
2023 年 11 月 21 日
% Read main set data
[spect map]=dicomread('I-131sphere10nisbah1.dcm');
info = dicominfo('I-131sphere10nisbah1.dcm');
%gp=info.SliceThickness;
spect=(squeeze(spect));%smooth3
Target_Volume = 26.67;
seedR1 = 58; seedC1 = 76; seedP1 = 45;
W = graydiffweight(spect, seedC1, seedR1, seedP1, 'GrayDifferenceCutoff', 1000000000);
fun = @(thresh)findvol(W, seedC1, seedR1, seedP1,thresh,Target_Volume);
nvars = 1;
A = []; b = []; Aeq = []; beq = []; lb = 0.0001; ub = 0.01; nonlcon = [];
gafun = @(thresh) fun(thresh).^2;
greyweight = ga(gafun, nvars, A, b, Aeq, beq, lb, ub, nonlcon);
residue = fun(greyweight);
volume = residue + Target_Volume;
greyweight
volume
function residue = findvol(W, seedC1, seedR1, seedP1, thresh, Target_Volume)
[BW, D] = imsegfmm (W, seedC1, seedR1, seedP1, thresh);
T = regionprops3(BW,'Volume');
residue = T.Volume(1) - Target_Volume;
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!