Anonymous user
Grayscale image: Difference between revisions
added J code
m (omit TI-BASIC) |
(added J code) |
||
Line 376:
A <tt>Gray</tt> image can be converted to an <tt>RGB</tt> image with <tt>Bitmap.RGB.toRGBImage</tt>, defined [[Basic bitmap storage|here]].
=={{header|J}}==
<lang j>
NB. converts the image to grayscale according to formula
NB. L = 0.2126*R + 0.7152*G + 0.0722*B
toGray=: 3 & $ @ (+/) @ <. @ (0.2126 0.7152 0.0722 & *)"1 1
</lang>
Example:
<lang j>
viewImage toGray myimg
</lang>
=={{header|MATLAB}}==
Built in colour to grayscale converter uses the following forumula:
|