Tech Tips

  1. Uncategorized
  2. 460 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

Uncategorized recent post

  1. Run Amazon FreeRTOS on M5Stack Core2 for AWS …

  2. Udacity Self-Driving Car Engineer Nanodegree …

  3. Install sbt 1.0.0 and run sample template

  4. Visualization of Neural Network and its Train…

  5. [Machine Learning]Created docker image includ…

関連記事

PAGE TOP