how to apply sauvola threshold in subtracting

3 visualizaciones (últimos 30 días)
yasmin ismail
yasmin ismail el 31 de Jul. de 2023
Editada: DGM el 2 de Ag. de 2023
How to apply sauvola threshold on image 1 to get the result as shown in 2?

Respuestas (1)

DGM
DGM el 31 de Jul. de 2023
Editada: DGM el 31 de Jul. de 2023
No thresholding has been applied to that image. It's had a slight gamma adjustment and then it's been inverted.
A = imread('1reg.png'); % original
B = imread('2reg.png'); % modified
% recreate B from A
B2 = 1.412 - 1.33*im2double(A).^0.456;
B2 = im2uint8(B2);
% compare the two
imshow([B B2],'border','tight')
Otherwise:
  2 comentarios
yasmin ismail
yasmin ismail el 1 de Ag. de 2023
they said they use sauvola for subracting and already I used the file exchange but I got different result
can you explin to me the equation you used B2 = 1.412 - 1.33*im2double(A).^0.456;
DGM
DGM el 2 de Ag. de 2023
Editada: DGM el 2 de Ag. de 2023
I don't know what the paper did or what the images mean. I'm not going to pay $30 read the paper. All I know is that there are two images which strongly appear to be related by a simple continuous value transformation. In order to provide substantiation for my suspicion, I registered the two images so that they could be compared.
% these images were manually registered
A = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1446877/1reg.png');
B = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1446872/2reg.png');
% put both A,B in unit-scale
A = im2double(A);
B = im2double(B);
% find the output values for each input value
% this could probably be simplified, but it doesn't matter here
Asort = unique(A(:));
Bsort = zeros(size(Asort));
for k = 1:numel(Asort)
Bsort(k) = mean(B(A==Asort(k)));
end
% plot the relationship between input and output intensity
plot(Asort,Bsort); hold on
% do a curve fit on the main portion of the TF curve
% ignore junk near zero
x = Asort(14:end);
y = Bsort(14:end);
ff = fit(x,y,'power2') % y = 1.412 - 1.33*x^0.456
ff =
General model Power2: ff(x) = a*x^b+c Coefficients (with 95% confidence bounds): a = -1.328 (-1.362, -1.294) b = 0.4568 (0.4392, 0.4745) c = 1.412 (1.376, 1.447)
% draw the estimated TF curve
xx = linspace(0,1,100);
yy = 1.412 - 1.33*xx.^0.456;
plot(xx,yy)
unitaxes
So the relationship between the given images is largely as suspected. Only near the origin (remember that y is inverted) does the data not fit the trend. Bear in mind that both A and B contain very few pixels in this region.
figure;
imhist(A) % there are only 8 pixels <= 0.1
Given the image source integrity (possibly scanned, compressed, transcoded, re-registered), we can expect that region of the curve to be dominated by errors. While it's possible that this narrow region is a consequence of some thresholding operation, it's reasonable to assume that it's just noise. If it is a piecewise curve, it's hard to back-calculate what it might be based on the available information.
yy = min(yy,0.9); % maybe?
figure
plot(Asort,Bsort); hold on
plot(xx,yy)
unitaxes

Iniciar sesión para comentar.

Categorías

Más información sobre 3-D Volumetric Image Processing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by