Sensitivity adaptive threshold : number of pixels ?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I am using the command T = adaptthresh( I , sensitivity ) with a sensitivity set to 0.3, I would like to know the exact number of pixels of the domain used to calculate the local mean intensity.
In the documentation it is possible to read " sensitivity is a scalar in the range [0 1] that indicates sensitivity towards thresholding more pixels as foreground."
Thank you for your help
Charles
0 comentarios
Respuestas (1)
DGM
el 12 de Oct. de 2024
The usage of the sensitivity parameter doesn't influence the neighborhood statistics. It's simply used as a polarity-independent proxy for the output scaling.
You can open up adaptthresh() and read it, or this is a simplified example of how it works using the default settings.
% an image in unit-scale float
inpict = imread('cameraman.tif');
inpict = im2double(inpict);
% parameters
sensitivity = 0.5; % default
fgpolarity = 'bright'; % default
nhoodsize = size(inpict)/8; % default
% convert normalized sensitivity to polarity-dependent scale factor
switch lower(fgpolarity)
case 'bright'
scalefactor = 0.6 + (1-sensitivity);
case 'dark'
scalefactor = 0.4 + sensitivity;
end
% construct filter kernel
nhoodsize = 2*round(nhoodsize/2) + 1; % round odd
fk = fspecial('average',nhoodsize);
% apply the filter and scale the threshold value
TH = imfilter(inpict,fk,'replicate');
TH = scalefactor*TH;
% compare against the IPT tool
THref = adaptthresh(inpict);
immse(TH,THref)
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!