why grey color looks violet?

Using (or providing) components based on the "Win32" framework

Re: why grey color looks violet?

Postby askom on Tue Dec 19, 2017 10:04 pm

you just average of R,G and B:

bits←⌊0.5+(+/[⎕IO]256 256 256⊤bits)÷3

It didn't work for me:-)

Only _weighted_ mean:

⍝ Y = .2126 * R^gamma + .7152 * G^gamma + .0722 * B^gamma

did the thing right.

/sasha

PGilbert wrote:Here is the code I am using to convert a color image to grey:

      GrayPic picname;bits
⍝ TRANSFORM THE COLORS OF A PICTURE ELEMENT INTO 256 SHADES OF GRAY
⍝ picname = NAME OF THE APL Picture ELEMENT
⍝ FOR A SINGLE PIXEL THE EQUATION IS: GRAY←256⊥3⍴⌊0.5+(+/256 256 256⊤RGB)÷3

:IF 0=⍴picname ⎕WI 'self' ⋄ picname," DOES NOT EXIST !" ⋄ →0 ⋄ :END
:IF ~'Picture'⊣(picname ⎕WI 'class') ⋄ picname," MUST BE A PICTURE !" ⋄ →0 ⋄ :END

bits←picname ⎕WI 'image'
bits←⌊0.5+(+/[⎕IO]256 256 256⊤bits)÷3
bits←256⊥(3,⍴bits)⍴bits
picname ⎕WI 'bitmap' bits


It is part of the workspace 'PicUtil' written in APL+Win that can be found on the APLWiki.

There is also a free dll (FreeImage) that can be used with more options. The Dyalog workspace with explanations can be found also on the APLWiki.

Regards,

Pierre Gilbert
askom
 
Posts: 35
Joined: Fri Apr 09, 2010 7:22 pm

Previous

Return to Windows: GUI, COM/OLE/ActiveX

Who is online

Users browsing this forum: No registered users and 1 guest