Reputation: 13
Can someone explain the last line of this MatLab expression? I need to convert this to C++ and I do not have any experience in matlab syntax.
LUT = zeros(fix(Max - Min),1);
Bin= 1+LUT(round(Image));
Image is an input image, Min and Max are image minimum and maximum grey levels. Is Bin going to be an array? What shall it contain? What are the dimensions, same as LUT or Image? What is the '1' stands for (add 1 to each member of array or a shift in array positions? I cannot find any example of this.
Thanks in advance.
Upvotes: 0
Views: 67
Reputation: 840
LUT
is a column vector that has a number of entries that is equal to the difference in maximum and minimum intensities in your image. LUT(round(Image))
retrieves the entries in your vector LUT
which are given by the command round(Image)
. The dimension of Bin
will be equal to the size of your matrix Image
, and the entries will be equal to the corresponding indices from the LUT vector. So, say you have a 3x3 matrix Image
, whose rounded values are as follows:
1 2 3
2 2 4
1 5 1
Then LUT(round(Image))
will return:
LUT(1) LUT(2) LUT(3)
LUT(2) LUT(2) LUT(4)
LUT(1) LUT(5) LUT(1)
And 1+LUT(round(Image))
will return:
1+LUT(1) 1+LUT(2) 1+LUT(3)
1+LUT(2) 1+LUT(2) 1+LUT(4)
1+LUT(1) 1+LUT(5) 1+LUT(1)
Note that this only works if all entries in round(Image)
are positive, because you can't use zero/negative indexing in the LUT
vector (or any MATLAB matrix/vector, for that matter).
Upvotes: 1