how to change the type of binarize threshold

8 ビュー (過去 30 日間)
mohd akmal masud
mohd akmal masud 2021 年 5 月 4 日
Hi Everyone,
can help me to solve this problem. i want to binarize my image dicom. the threshold is 40% from my max pixel. then i wrote this command.
But the error pop up below. Anyone can help me?
clc
clear all
[spect map]=dicomread('I-131sphere10nisbah1');
info = dicominfo('I-131sphere10nisbah1');
%gp=info.SliceThickness;
spect=(squeeze(spect));%smooth3
maxx = max(max(max(spect)));
T = 3189*0.4;
BW = imbinarize(spect,T);
%open image
figure
imshow3D(BW)
% CC = bwconncomp(BW11);
% [r, c] = cellfun(@(x) ind2sub(size(BW11), x), CC.PixelIdxList, 'UniformOutput', 0);
T = regionprops('table', BW,'Area','Centroid')
ERROR
Error using imbinarize
Expected input number 2, Threshold, to be one of these types:
double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64
Instead its type was table.
Error in imbinarize>validateT (line 268)
validateattributes(T,{'numeric'},{'real','nonsparse','3d'},mfilename,'Threshold',2);
Error in imbinarize>parseInputs (line 204)
options.T = validateT(varargin{1},size(I));
Error in imbinarize (line 134)
[I,isNumericThreshold,options] = parseInputs(I,varargin{:});
  4 件のコメント
mohd akmal masud
mohd akmal masud 2021 年 5 月 4 日
then the T is not this one, double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64.
it just the one value
DGM
DGM 2021 年 5 月 4 日
I read the error message the first time. Like I said. The code you posted doesn't appear to correspond to the error message. The workspace is cleared
clear all
At this point, no prior instance of T exists to impose class on this assignment:
T = 3189*0.4;
At this point, T is of class 'double'. It's not a table. It can't be a table.
Now I don't know what spect is, but if I trust that the error is correct in saying that the problem argument is argument 2, then my comment stands. I'm left to assume that the error message was caused by some version of this code other than what you've pasted.
If you want anyone to try to deal with this further, you'll have to include the image. As it is, I can run it on my sample dcm files without error -- as I explained should be expected.

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

採用された回答

Constantino Carlos Reyes-Aldasoro
Constantino Carlos Reyes-Aldasoro 2021 年 5 月 4 日
I agree with the previous comments, the first T is not a table. So two comments
1) do not use T for a value first and then for a table, use separate variables and better named, called one threshold_1 and the other table_1 or something like that
2) if you want to compare pixels above a threshold just try
BW = spect>T;
or
BW = spect>threshold_1;
And see if that works
  2 件のコメント
DGM
DGM 2021 年 5 月 4 日
I can't believe I missed that T was being reused as a table later on. Talk about target fixation.
Constantino Carlos Reyes-Aldasoro
Constantino Carlos Reyes-Aldasoro 2021 年 5 月 4 日
Well, that happens, that is why it is better to have longer names than x,y,z,t that are an inheritance of the time that memory was scarse. Hope this has solved your problem.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by