Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

mat2gray in c++

92 views
Skip to first unread message

vj

unread,
Apr 7, 2012, 10:45:28 PM4/7/12
to
hi,

i am trying to convert a matlab code to a c++ code. i am using 2011a, coder toolbox. When i tried to convert, it said mat2gray is not supported. So, I am wondering if there is some other matlab function on cpp function that can produce the same result as mat2gray.

plz help.

ImageAnalyst

unread,
Apr 7, 2012, 11:47:33 PM4/7/12
to
---------------------------------------------------------------------
I don't think it can translate m code into c++.
You can do tha same as mat2gray just by subtracting the min value,
dividing by the range (max-min) and multiplying by 255 and then
casting to uint8

m8 = (m - maxValue) * 255 / (maxValue - minValue);

vj

unread,
Apr 8, 2012, 4:09:13 PM4/8/12
to
ImageAnalyst <imagea...@mailinator.com> wrote in message <656ca411-fa8a-4c91...@s7g2000yqm.googlegroups.com>...
thank you image analyst :)

vj

unread,
Apr 8, 2012, 9:32:10 PM4/8/12
to
"vj " <vijay....@gmail.com> wrote in message <jlsr98$dc5$1...@newscl01ah.mathworks.com>...
i suppose it needs to be like this.

m8 = (m - minValue) * 255 / (maxValue - minValue);
0 new messages