how to calculate otsu threshold value for the matrix given [1 3 4 5 3 2; 4 6 2 4 1 9; 0 4 9 5 8 3; 2 4 9 4 2 1; 0 1 9 3 4 8; 5 6 4 7 3 8]
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
please help me with the simples code possible.
0 Commenti
Risposte (1)
Image Analyst
il 22 Set 2022
grayImage = uint8([1 3 4 5 3 2; 4 6 2 4 1 9; 0 4 9 5 8 3; 2 4 9 4 2 1; 0 1 9 3 4 8; 5 6 4 7 3 8])
threshold = graythresh(grayImage) % Find threshold using Otsu method.
% If it's uint 8 you want to multiply by 255
threshold = 255 * graythresh(grayImage)
2 Commenti
Image Analyst
il 22 Set 2022
Not sure what that means. An element of the image is a single number and the mean is the value of the pixel, the variance is zero, and the max and min are again the value of the pixel.
If you want it of just the part above the threshold you'd do
grayImage = uint8([1 3 4 5 3 2; 4 6 2 4 1 9; 0 4 9 5 8 3; 2 4 9 4 2 1; 0 1 9 3 4 8; 5 6 4 7 3 8]);
threshold = graythresh(grayImage); % Find threshold using Otsu method.
% If it's uint 8 you want to multiply by 255
threshold = 255 * graythresh(grayImage)
mask = grayImage > threshold;
meanGrayLevel = mean(grayImage(mask))
varGrayLevel = var(double(grayImage(mask)))
stDevGrayLevel = std(double(grayImage(mask)))
minGrayLevel = min(grayImage(mask))
maxGrayLevel = max(grayImage(mask))
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!