A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
10
Task/Bitmap-Read-a-PPM-file/J/bitmap-read-a-ppm-file-1.j
Normal file
10
Task/Bitmap-Read-a-PPM-file/J/bitmap-read-a-ppm-file-1.j
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
require 'files'
|
||||
|
||||
readppm=: monad define
|
||||
dat=. fread y NB. read from file
|
||||
msk=. 1 ,~ (*. 3 >: +/\) (LF&=@}: *. '#'&~:@}.) dat NB. mark field ends
|
||||
't wbyh maxval dat'=. msk <;._2 dat NB. parse
|
||||
'wbyh maxval'=. 2 1([ {. [: _99&". (LF,' ')&charsub)&.> wbyh;maxval NB. convert to numeric
|
||||
if. (_99 0 +./@e. wbyh,maxval) +. 'P6' -.@-: 2{.t do. _1 return. end.
|
||||
(a. i. dat) makeRGB |.wbyh NB. convert to basic bitmap format
|
||||
)
|
||||
3
Task/Bitmap-Read-a-PPM-file/J/bitmap-read-a-ppm-file-2.j
Normal file
3
Task/Bitmap-Read-a-PPM-file/J/bitmap-read-a-ppm-file-2.j
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
myimg=: readppm jpath '~temp/myimg.ppm'
|
||||
myimgGray=: toColor toGray myimg
|
||||
myimgGray writeppm jpath '~temp/myimgGray.ppm'
|
||||
|
|
@ -0,0 +1 @@
|
|||
Import["file.ppm","PPM"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue