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).

175 questions
1
vote
1 answer

Reading pgm file byte by byte gets corupted data

int i, j; for (i = (*pgm).height - 1; i >= 0; i--) for (j = 0; j < (*pgm).width; j++) { fscanf(file, "%c", &(*pgm).data[i][j]); } } This is a part of my function for reading a PGM file byte by byte. In…
1
vote
1 answer

Create a grayscale image from (32-bit floating point) values in Java

With Java, a grayscale image from an array with (32-bit floating point) values. Could I use BMP or PGM? What its the best image format with no compression for this array with these (32-bit floating point) values?
user4888784
1
vote
1 answer

Open PGM image in Java

I need to read a PGM image and get its points in Java. Anyone knows a good library to do that? I have to display an image with PGM format and then get the values from that image to draw a path with A*. Cumps.
arturataide
  • 363
  • 2
  • 11
1
vote
2 answers

how to convert a jpg image to pgm format in cpp

I want to covert a .jpg image to a .pgm image.The image is being obtained from a tcp socket which has live streaming by a OPENCV program. In matlab I used the imread function to do it. How do I do it in cpp? I am working in linux platform. Is there…
wireless_lab
  • 177
  • 1
  • 4
  • 18
1
vote
1 answer

Using Floyd–Steinberg dithering not working

I'm trying to implement the floyd algorithm but it seems it doesn't works. I used the pseudocode algorithm from wikipedia without floyd http://img15.hostingpics.net/pics/298623Capturedcran20140226165024.png with floyd…
Pépito
  • 57
  • 4
  • 11
1
vote
1 answer

My function is copying a PGM image file to PPM in a different way

I have a very simple function that saves a PPM image: void WriteCImage(CImage *cimg, char *filename) { FILE *fp; int i,n; fp = fopen(filename,"w"); fprintf(fp,"P6\n"); fprintf(fp,"%d %d\n",cimg->C[0]->ncols,cimg->C[0]->nrows); …
mad
  • 2,677
  • 8
  • 35
  • 78
1
vote
0 answers

How to save PGM bytes to a file

We are taking a UIImage and converting it to PGM as an 8-bit grayscale representation of the image. The result is an unsigned char array of the bytes. I want to write this to a file to check what it has converted. When I do that using: NSData…
1
vote
1 answer

How to read / write ASCII .pgm file

I am new to filing and have not much idea about it. I have written a code that tries to read an ASCII .pgm file named owl.pgm and writes it as myowl.pgm file: #include const int MAXHEIGHT=221; unsigned char *bitmap[MAXHEIGHT]={'\0'} ;//…
zorroz
  • 21
  • 2
  • 5
1
vote
2 answers

Sublassing NSImageRep to support new file format (pgm)

Hi everyone! It is my first post here. I am quite new in objective-c so maybe my question is not so hard but It is a problem for me. I've searched the web and didn't find any useful hints for me... I am writing a program in Objective-c in Xcode. I…
zioolek
  • 421
  • 5
  • 15
1
vote
2 answers

how to change the default value of maximum grey level while writing pgms using opencv?

I am writing pgm using opencv using python as follows... cv.SaveImage("a.pgm",np.array(image.astype(np.uint16))) So, I am casting my data to be unsigned 16 bits. The prob is that the maximum value of the gray level is set to 65535 while the pgm…
Shan
  • 18,563
  • 39
  • 97
  • 132
0
votes
2 answers

Writing PGM file in C doesn't work

I am trying to write a PGM file in a C program, but once it is written, if I try to open it to view the image I am told the image file format can't be determined. However, if I create a new file in geany, copy the data over, and then save THAT as a…
Luke
  • 2,434
  • 9
  • 39
  • 64
0
votes
1 answer

ZeroMQ EPGM Python. Receiver can't get messages

Trying to use EPGM with ZeroMQ, PUB/SUB pattern, but can't receive message on client side. How to fix code? I am running this code on Ubuntu with wireless connection. wlp2s0: flags=4163 mtu 1500 inet 192.168.1.122 …
Sergey Ko
  • 11
  • 2
0
votes
0 answers

Supporting different variations for reading file header (see Update)

I am trying read the header for a PGM file, which I found could have the follow variations: P2 255 255 255 or P2 255 255 255 or P2 255 255 255 right now, I got this code: std::ifstream file(file_name); std::string line_one, line_two,…
Kleber Mota
  • 8,521
  • 31
  • 94
  • 188
0
votes
1 answer

Error when trying read pixel data from PGM file

I am trying implement a c++ class to read a PGM file. I can read the header of file (magic number, width, height and max_value) without problem, but when I try read the pixel data, I got an error related to the conversion of the string with…
Kleber Mota
  • 8,521
  • 31
  • 94
  • 188
0
votes
2 answers

Converting from pgm to pbm but getting wrong output

I've written a program that takes a PGM image as input and converts it to a PBM file. However, the image I get as output is incorrect. I determine if a pixel is white if its value is bigger than (max+1)/2 then use putchar() to place the character…