how to change the type of binarize threshold
Mostrar comentarios más antiguos
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 comentarios
Something doesn't seem right with this. If spect or something were a table and you were calculating T from it, then maybe it would be, but you're not. You're calculating maxx and then never using it. T is a literal. The code you're posting doesn't seem to correspond to the error.
maxx = max(max(max(spect))); % fwiw, this is the same as max(spect(:))
T = 3189*0.4; % i would expect this to be T = maxx*0.4; not a literal
BW = imbinarize(spect,T);
Also, keep in mind that calculating T based on the maximum value alone only really works if you assume that black is zero. Lots of Dicom images (all the ones I've ever used) are signed integer datatypes, meaning black is often some negative value. If that's the case, then you need to know the actual image data range.
Not knowing what's missing, I can only guess.
mohd akmal masud
el 4 de Mayo de 2021
mohd akmal masud
el 4 de Mayo de 2021
DGM
el 4 de Mayo de 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.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Image Processing Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!