Production Level Knowledge & Tips

  1. 未分類
  2. 19 view

[Haskell]Make PGM File part1

What I want to do

I’ll output PGM file with Haskell to do Image Processing.

Program

At first only header output.
main = do
    -- PGM Header
    let pgm_type = "P5\n"
    let pgm_comment = "# PGM type grayscale image\n"
    let pgm_size = (255,255)
    let pgm_max_brightness = 255

    let pgm_size_string = (show (fst pgm_size)) ++ " " ++ (show (snd pgm_size)) ++ "\n"
    let pgm_max_brightness_string = (show pgm_max_brightness) ++ "\n"
    let pgm_header = pgm_type ++ pgm_comment ++ pgm_size_string ++ pgm_max_brightness_string
    -- Main
    writeFile "test.pgm" pgm_header
Compile and run.
$ghc pgm.hs
$./pgm
$cat test.pgm
P5
# PGM type grayscale image
255 255
255

未分類 recent post

  1. Install sbt 1.0.0 and run sample template

  2. Visualization of Neural Network and its Train…

  3. [Machine Learning]Created docker image includ…

  4. [Node.js]How to write batch script with Node.…

  5. [Hive]Get top n items for each category

関連記事

PAGE TOP