プログラミング + アカデミック + 何か面白いこと

  1. Academic
  2. 0 view

[Haskell]Make PGM File part1

Pocket

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
Pocket

Academic recent post

  1. [Just Touch]Microsoft Quantum Development Kit…

  2. Visualization of Neural Network and its Train…

  3. [Machine Learning]Created docker image includ…

  4. [OpenCV][Ruby]Auto check web page design corr…

  5. [MachineLearning]How to introduce to real pro…

関連記事

PAGE TOP