Using the Scala Breeze library :
How can I convert an instance of a breeze.linalg.DenseMatrix of Int values to a DenseMatrix of Doubles (both matrices have the same dimensions)?
(I am trying to get a image/picture in a matrix for image processing using Breeze)
fotNelton's answer works. Another option is:
dm.mapValues(_.toInt)
or
dm.values.map(_.toInt)
As of Breeze 0.6, you can also say:
convert(dm, Int)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With