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
0
votes
1 answer

Perl reading PGM files

I am having trouble even reading a pgm file in perl. Does anyone know how to do this? (pgm file is the binary version not ASCII) This is my code, I was attempting to only read the header portion of pgm file: #!/usr/bin/perl open(TEST,…
user3531263er
  • 423
  • 1
  • 4
  • 20
0
votes
1 answer

Adding Noise to a PGM image using 2D arrays and for loops?

I have an assignment and I am trying to create noise within an image similarly to how I did here: public static short[][] brighten(short[][] orig, short amount) { short[][] returnArray = new short[orig.length][orig[0].length]; for(int i =…
Cole
  • 5
  • 6
0
votes
1 answer

Cropping an Image Using 2D Arrays?

I am completely lost on this assignment, any help would be appreciated guys! I am reading in a PGM image and making changes to it. I have already written some code to increase the brightness on it, but I don't know how to crop it. My brighten code…
Cole
  • 5
  • 6
0
votes
2 answers

C sscanf() returning zeros when reading a pgm file

I am trying to read a pgm file and put it into an array for an assignment and I have it to where I can get each line into a string then I try to sscanf each line to get the values, but it always puts a zero in for num no matter what it really is. It…
SpencerJL
  • 203
  • 1
  • 2
  • 8
0
votes
0 answers

Try to convert a binary image file to ascii.

I am so stuck. I'm trying to create an ascii text file that stores the values of a .PGM file. I can read the file fine, the header is in ascii and it reads perfectlly. But the problem is, I need to read everything after the 16byte header as ascii…
0
votes
1 answer

error when saving .pgm images with opencv

I want to save every single frame of a real time video in .pgm format. I am working with opencv 2.4.8 in c++. My problem is that despite all frames are saved and phenomenically in the right format (for example as frame_1.pgm) , when I open them they…
m_papas
  • 91
  • 1
  • 12
0
votes
1 answer

Creating a video file from a group of PGM files in python

My python program generates a collection of binary files. I create pgm (portable bitmap files) using this binary data. I would like to create a video using each of the pgm files as a frame in my video. I have had a look an mencoder but I dont think…
mikip
  • 1,677
  • 6
  • 25
  • 35
0
votes
0 answers

Making PGMs negative

I'm a bit lost as to how I would take a pgm file stored into a vector and flip the order of the cells so as to make the final image a negative flip. I don't want the answer handed to me, I would just like some tips in the right direction! Thanks!
0
votes
2 answers

Read binary 16bit streamfile and write to 16bit PGM (C++)

this is my first Post as I came along with using the search function so far. But now I wasted a whole day on the following issue: I recorded a 12bit (written as 16bit) grayscale video and wrote it directly into a binary stream-file (no headers or…
0
votes
1 answer

Median filter of a pgm image

I have to write a program that replaces each pixel with the median value of it and its 8 neighbors. What I have will compile but when i try to create a new image im getting multiple errors. Help is appreciated. Here's the stacktrace: Exception in…
0
votes
1 answer

finding the average of a 2-d array in a pgm file in java

Hey I am suppose to build a low pass filter for a 2-d array for a pgm file. The program is suppose to replace each pixel with the average of it and its 8 nearest neighbors. I am stuck and have no idea what i'm doing wrong. thanks for the help. Now…
0
votes
1 answer

getting different result of pgm pixel value in c++ and matlab

I understand there's no reason for implementing a function that reads pixel values of a pgm image on c++, but I have to do it for my assignment. For accuracy reason, after I read the pixel values, I compared it with the pixel values read in matlab…
Tal_
  • 761
  • 2
  • 6
  • 13
0
votes
1 answer

cannot read correct pgm pixel values

I have a really weird error, so I'm trying to read a pgm image by loading its pixel values into an array, I was able to correctly read in its version, height, width, and maximum possible pixel value. However, when I start reading the pixel values, I…
Tal_
  • 761
  • 2
  • 6
  • 13
0
votes
1 answer

Matlab is opening a pgm image with different values using imread

I have a pgm image with 1251 different pixel values, ranging from 0 to 1250. I know this because I can open this image file with kate and see the values. But when I open the same file using Matlab's imread, it also returns me 1251 different pixel…
mad
  • 2,677
  • 8
  • 35
  • 78
0
votes
3 answers

Passing Structures in C

I am working on a program that is supposed to handle a PGM image file of the form P2 24 7 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 11 11 11 0 11 0 0 0 11 0 0 11 0 0 0 11 0 0 0 …
Evan
  • 508
  • 1
  • 5
  • 18