threshold multiple values at the same time

4 vues (au cours des 30 derniers jours)
Matpar
Matpar le 6 Août 2019
Commenté : Walter Roberson le 7 Août 2019
Hi am I trying to find the value of a global threshold (mean, median, 50, 100, 150, 200)
Can someone assist me asap please?
TIA!
  3 commentaires
Matpar
Matpar le 6 Août 2019
Modifié(e) : Matpar le 6 Août 2019
I am trying to do a global threshold for the given values 50, 100, 150, 200
all at once and have matlab project all images respectfully!!
I do not know how to start the syntax hence the reason for me asking!!!
Help if you can please!!!
Walter Roberson
Walter Roberson le 6 Août 2019
What does it mean to do a global threshold for the given values 50, 100, 150, 200 ?

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 6 Août 2019
nd = ndims(YourImageArray);
Thresholded_arrays = bsxfun(@le, YourImageArray, reshape([50, 100, 150, 200], [ones(1,nd), 4]) );
Now Thresholded_arrays is one higher dimension than your original array. For example if your original array was 512 x 768 x 3 x 128 (that is, a stack of 128 RGB images each of which is 512 x 768 pixels), then Thresholded_arrays would be 512 x 768 x 3 x 128 x 4, and Thresholded_arrays(:,:,:,:,1) would be YourImageArray thresholded at value 50.
  15 commentaires
Walter Roberson
Walter Roberson le 7 Août 2019
Adaptive thresholding and local thresholding do not use constants. The code I showed is already for global thresholding.
Walter Roberson
Walter Roberson le 7 Août 2019
"If you convert a number that is larger than the maximum value of an integer data type to that type, MATLAB sets it to the maximum value. Similarly, if you convert a number that is smaller than the minimum value of the integer data type, MATLAB sets it to the minimum value."
The calculation A+B in uint8 is like
uint8( max(min(double(A)+double(B),255), 0) )
There is no need to go through and test whether A+B is in the range 0 to 255, because that kind of limit is already built-in to the way that uint8() is defined to operate.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by