Questions tagged [pgm]

PGM is a grayscale image format used by the Netpbm library and other graphics software.

Portable Gray Map (PGM) is a simple image format for grayscale images.

The format allows data to be stored in either ASCII or binary format. PGM is the native format of the Netpbm graphics library and the format is described on the Netpbm web site. It is part of a family of formats including , , and , collectively tagged (the original name for what is now the Netpbm library).

168 questions
24
votes
6 answers

"Standard" RGB to Grayscale Conversion

I'm trying to write a converters algorithm that takes a JPEG image and returns its PGM (Portable Gray Map) version. The problem is that I can't understand how the "official" JPG->PGM convertitors work in terms of what value to assign to the final…
TheUnexpected
  • 2,871
  • 5
  • 25
  • 58
17
votes
5 answers

Numpy and 16-bit PGM

What is an efficient and clear way to read 16-bit PGM images in Python with numpy? I cannot use PIL to load 16-bit PGM images due to a PIL bug. I can read in the header with the following code: dt = np.dtype([('type', 'a2'), …
mankoff
  • 2,022
  • 5
  • 22
  • 38
14
votes
1 answer

Segmentation faults occur when I run a parallel program with Open MPI

on my previous post I needed to distribute data of pgm files among 10 computers. With help from Jonathan Dursi and Shawn Chin, I have integrate the code. I can compile my program but it got segmentation fault. I ran but nothing happen mpirun -np 10…
arep
  • 155
  • 1
  • 2
  • 7
8
votes
2 answers

reading pgm images with cv2 in python

I want to read pgm image in python. I use cv2.imread('a.pgm') but it returns wrong results. In Matlab, I use imread and get the right result which is a single channel 16-bit image. But cv2.imread in python returns a 3-channel image and the pixel…
Liang Xiao
  • 1,292
  • 1
  • 12
  • 18
8
votes
2 answers

Read a pgm file in python

I am interested in reading a pgm file in python as a numerical file/matrix Right now I open the file with f = open('/home/matthew/NCM/mdb001.pgm', 'rb') When I read the first line, it looks as expected r.readline() produces 'P5\n' and the next…
Matt Cremeens
  • 4,641
  • 6
  • 29
  • 59
5
votes
3 answers

Python and 16-bit PGM

I have 16-bit PGM images that I am trying to read in Python. It seems (?) like PIL does not support this format? import Image im = Image.open('test.pgm') im.show() Shows roughly the image, but it isn't right. There are dark bands throughout and img…
mankoff
  • 2,022
  • 5
  • 22
  • 38
5
votes
1 answer

How to display PGM image using OpenCV

I'm trying to load and display a .PGM image using OpenCV(2.4.0) for C++. void open(char* location, int flag, int windowFlag) { Mat image = imread(location, flag); namedWindow("Image window", windowFlag); imshow("Image window", image); …
John Smith
  • 707
  • 1
  • 10
  • 36
4
votes
2 answers

Viewing .pgm images in Matlab

I have been provided with a dataset consisting of .pgm images to be used for some coding in Matlab. I was just wondering if it is possible to view the same image as a .jpeg/.png in Matlab itself? Thanks
user1105630
  • 55
  • 1
  • 1
  • 5
4
votes
2 answers

How to read in data from a pgm file in C++

So far I can read every line and print it out to the console: void readFile(){ string line; ifstream myfile("example1.pgm"); if (myfile.is_open()){ while (myfile.good()){ getline (myfile,line); cout << line; …
ostegg548
  • 73
  • 1
  • 2
  • 6
4
votes
2 answers

Help on adding plug-in to Java ImageWriter

I am trying to save a BufferedImage as a PNM file. I already installed the JAI (Java Advanced Imaging), and have the PNMWriter plug-in imported. However, I don't know how to add it to my ImageWriter so it can write in .pnm. When I run…
Pedro Cimini
  • 165
  • 1
  • 1
  • 7
4
votes
1 answer

PNG to PGM conversion without quality loss

So, I have a PNG image file like the following example, and I need it to be converted into PGM format. I'm using Ubuntu and Python, so any of terminal or Python tools would suit just fine. And there sure is a plenty of ways to do this: using…
Romitas
  • 55
  • 1
  • 5
3
votes
0 answers

Getting "malloc(): memory corruption" when loading images in TKinter

I am working on a project, and one of our spec is to be able to display PGM images with TKinter. Well, for some reason, after switching the image a specific number of times, our application would always end with a Segmentation Fault... For debugging…
RhiobeT
  • 31
  • 4
3
votes
1 answer

How to read PGM P2 image in Python

So first, I'm in a mission on AI's college group. I have a dataset with many faces in PGM P2(ASCII) format. Before starting Neural Network proccess, I need to extract the array of pixels from images, but I can't found a way to read these images in…
victor2605
  • 33
  • 4
3
votes
2 answers

Quickest way to extract the bits of the colors in a .pgm image?

I've got a hundred 128 x 128 .pgm files with some shapes on them and I think their color scale is 255 (not sure on this one though, so it'd be nice if a solution could also take that in consideration) and I need to extract these colors to process…
Peewee
  • 33
  • 2
3
votes
3 answers

How to initialize structure in main function

I am trying to write simple pgm file reading C program. I had to create simple structure: typedef struct pgmImage { int R; //rows int C; //collumns int G; //grey scale int **pix; // array of pixels }Image; Now i have to initialize…
Norrec
  • 37
  • 4
1
2 3
11 12