How can I accurately convert the remote sensing image into a matrix in Rstudio?

Hello @yiboliu ,
welcome in the community.
I hope that you already have an answer to your question.
If so please answer your own question and indicate it as solved.
If not we can only redo your analysis if you provide us a reproducible example .
By providing us a small tif file (e.g. a data file from one of the packages) that leads to the same problem, you make it easier for us to help you.