1
可以使用itk::NumericTraits
獲得某種類型的0和1。因此,我們可以在野外看到這種代碼:NumericTraits Zero and One
const PixelType ZERO = itk::NumericTraits<PixelType>::Zero;
const PixelType ONE = itk::NumericTraits<PixelType>::One;
這感覺很沉重,很難閱讀。作爲程序員,我更喜歡更實用的版本,例如:
const PixelType ZERO = 0;
const PixelType ONE = 1;
但是它是完全等價的嗎?我認爲演員是在編輯過程中完成的,所以兩個版本的速度應該是相同的。如果是這樣的話,爲什麼有人想用itk::NumericTraits
得到0和1?必須有我沒有看到的優勢。