I'm new at Matlab. You may find this question silly but I really wonder if the statement below is a pass-by-value operation or pass-by-reference operation.
I = imread('logo.png');
binaryImage = im2bw(I, 0.4);
Itemp = binaryImage;
Does the Itemp
is a new matrix whose values are copied from binaryImage
, or it is just a pointer to the binaryImage
?
It's pass by reference, until you modify Itemp
.
When you modify Itemp
matlab will copy binaryImage
to Itemp
and then modify it.
I made some interesting tests a while a go. If you do:
A=rand(100);B=A;C=B;D=A;E=B;
only one copy is kept in memory. If you modify A
A(1)=1;
Then, matlab make one new copy of the matrix for the new A
, and the variables B
,C
,D
,E
still point to the matrix of the old A
.
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