how to change the type of binarize threshold
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
mohd akmal masud
il 4 Mag 2021
Commentato: Constantino Carlos Reyes-Aldasoro
il 4 Mag 2021
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 Commenti
DGM
il 4 Mag 2021
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.
Risposta accettata
Constantino Carlos Reyes-Aldasoro
il 4 Mag 2021
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 Commenti
DGM
il 4 Mag 2021
I can't believe I missed that T was being reused as a table later on. Talk about target fixation.
Constantino Carlos Reyes-Aldasoro
il 4 Mag 2021
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.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Image Processing Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!