> From: Jonathan Lettvin
>
> It is not clear that 'image3' is cross platform like 'platimg'.
> If switching to platimg is preferable, please show conversion from RGB
> plane to R G B planes.
Hi Jonathon,
image3 is crossplatform - it installs & uses a library of image functions to
work with images - libimage3.dll, libimage3.so or libimage3.dylib depending on
OS.
platimg is also crossplatform but uses image manipulation frameworks native on
each platform.
load 'media/image3 media/platimg'
fn1=: jpath '~addons/image3/hy_fly_di.png'
img1=: read_image fn1 NB. read image using image3
img2=: readimg fn1 NB. read same image using platimg
img2 -: img1
0
$img1
880 880 3 NB. R G B planes
$img2
880 880 NB. RGB plane
If you decide to use platimg it contains a utility to convert from R G B planes
to RGB plane - you want to do the reverse
img2 -: rgbmat_pplatimg_ img1
1
rgbmat_pplatimg_
3 : 0
'empty data' assert 0<#y
'rank error' assert 3>:#$y
while. 2 > #$y do. y=. ,:y end.
if. 3=#$y do.
assert 3 e. $y
y=. 256#.(|:~ (i.3) A.~ _1 + 2 ^ 2 - 3 i.~$) y
end.
y bOR 24 bSH 16bff NB. opacity
)
The key line that does the conversion is:
y=. 256#.(|:~ (i.3) A.~ _1 + 2 ^ 2 - 3 i.~$) y
You need to work out how to do the reverse.
The following is the same expression using explicit (rather than tacit)
notation which you may find easier to understand.
$ 256#. img1 |:~ 0 1 2 A.~ _1 + 2 ^ 2 - 3 i.~ $img1
880 880
It might be worth checking out #:
Hope that is of some use:
Regards,
Ric
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm