Sensitivity adaptive threshold : number of pixels ?

7 Ansichten (letzte 30 Tage)
Charles Roux-Pertus
Charles Roux-Pertus am 13 Dez. 2016
Beantwortet: DGM am 12 Okt. 2024
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

Antworten (1)

DGM
DGM am 12 Okt. 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)
ans = 4.5751e-29

Community Treasure Hunt

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

Start Hunting!

Translated by