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

Problem in Implementing a Graphical Model Using Pyro

I am trying to implement this graphical model using Pyro: My implementation is: def model(data): p = pyro.sample('p', dist.Beta(1, 1)) label_axis = pyro.plate("label_axis", data.shape[0], dim=-3) f_axis = pyro.plate("f_axis",…
Arash Khoeini
  • 1,276
  • 1
  • 11
  • 17
1
vote
1 answer

Writing a PGM file from a vector

I am writing a program to manipulate PGM files by taking an input PGM, storing the data in a vector, using the vector of data to create a new vector and so on and so forth until I use the last vector to create an output PGM file. I've…
esljkfgh
  • 25
  • 1
  • 5
1
vote
2 answers

How to read a .pgm image file in a 2D double array in C

The question is quite simple: How to read a .pgm image file into a 2D double array in C. I do not have a .pgm buffer in memory. I would like to read it from the disk into memory. Would really appreciate if I could get a code snippet. Thank You.
SauravBhattacharya
  • 631
  • 3
  • 9
  • 24
1
vote
0 answers

Writing into a PGM image

I would like to write some 1 into a PGM image just to create a black rectangle. But I don't know what to give to fwrite and if it could work. #include struct rec { char x; }; int main() { int counter; FILE *ptr_myfile; struct rec…
1
vote
2 answers

Program only rotates square images properly

I have been trying to work with PGM files on C++, getting their negatives etc. Now once I started on rotation, I had a rough pseudocode on how we're gonna rotate the matrix, here's the result on a numerical matrix: Rotated matrix test On the…
1
vote
2 answers

Open MPI to distributed and manipulate 2d array in PGM files

I need to use Open MPI to distribute 2d-array in the PGM file among 10 working computers. Then I need to manipulate each value of the array to get a negative image (255-i) and then print the output back. I'm thinking of using mpi_scatter and…
arep
  • 155
  • 1
  • 2
  • 7
1
vote
1 answer

Combine two commands using GNU parallel for OCR project

I would like to write a script which runs a command to OCR pdfs, which deletes the resulting images, after the text files has been written. The two commands I want to combine are the following. This command create folders, extract pgm from each PDF…
Til Hund
  • 1,543
  • 5
  • 21
  • 37
1
vote
1 answer

JavaScript Convert Canvas To PGM

I am trying to convert canvas in JavaScript to pgm. After i convert the file and download it to my desktop, it has the pgm extension, but when i open it with editor it is coded as png. i think if JavaScript didn't recognize the extension that you…
Ala
  • 13
  • 3
1
vote
2 answers

Displaying Portable Graymap (PGM) images in Universal Windows App (c#, XAML)

I need to display .pgm images in my Universal Windows App. XAML Image control does not directly support .pgm images so I need to work around it. There are many examples on the internet of opening .pgm files in c#, but all of these rely on using the…
zvjeverica
  • 21
  • 5
1
vote
2 answers

Using DataInputStream after BufferedReader

A sample binary PGM file is as follows: P5 # This is a comment 10 10 255 #image intensity information in bytes that I am unable to copy paste here like When I try to read the file using the following code: import java.io.*; public class…
cnova
  • 725
  • 2
  • 9
  • 22
1
vote
1 answer

Converting Binary PGM Files to ASCII PGM Files using Java? Using FileWriter gives empty file

How can I convert Binary PGM Files to ASCII PGM Files using Java? When I use the following code, I am unable to write ASCII values in the B.pgm. I've tried using dos.writeInt also. FileInputStream inRaw = null; FileOutputStream outRaw = null; try { …
cnova
  • 725
  • 2
  • 9
  • 22
1
vote
1 answer

How to read a PGM image properly in C

I'm here to ask you a little help. I'd like to write a C code that reads a PGM file (P2, not binary) and I have found many ways to do it on the Web. The problem is that every time I try to read some PGM images I have as examples on my PC, I'm not…
sibly22
  • 73
  • 1
  • 1
  • 11
1
vote
1 answer

How can I display 2 or more .pgm images using CImg library in C++?

Im trying to load and display 2 .pgm files in c++ So far I have: #include #include using namespace std; using namespace cimg_library; int main() { CImg image1("pic1.pgm"); image1.display(); …
ProNoobSry
  • 31
  • 5
1
vote
1 answer

pgm-file I/O gives me half of data

so i wrote an I/O for a pgm-file. My program reads a pgm and writes the data of it to a new pgm-file. But somehow it just writes the half of the data and i spent hours of searching for the mistake but couldn't find it. Here is the code: #include…
thedude
  • 51
  • 8
1
vote
1 answer

Load an OpenCV::Mat as a .pgm

I have a program which loads a .PGM image file into std::vector m_data : void LoadPgm( std::string const& filename ){ std::ifstream in( filename.c_str(), std::ios::binary ); if ( !in ){ std::cerr << "Error in Image::LoadPgm: Could not open…
sat
  • 11
  • 2