Questions tagged [pbm]

pbm - NetPBM bi-level image format

The PBM format is a lowest common denominator monochrome file format. It serves as the common language of a large family of bitmap image conversion filters. Because the format pays no heed to efficiency, it is simple and general enough that one can easily develop programs to convert to and from just about any other graphics format, or to manipulate the image.

The name "PBM" is an acronym derived from "Portable Bit Map."

This is not a format that one would normally use to store a file or to transmit it to someone -- it's too expensive and not expressive enough for that. It's just an intermediary format. In it's purest use, it lives only in a pipe between two other programs.

Source: The NetPBM manual

21 questions
3
votes
1 answer

How to create in ascii square, triangle, rectangle or circle with C++ and save it to portable bitmap file?

I don't know how to save in lines 0 and 1 to create a figure. This is my code, which generates lines with zeros. I need to create a square or trianlge, or rectangle (doesn't matter). Just need to know how to do that properly and save to pbm…
user2028342
2
votes
1 answer

pbm-file created with Python only works when copy&pasted in new text-file

When I create a random image in .pbm-format (code below) and output the result in a .pbm-file, the file appears to be corrupt (cannot be opened e.g. with GIMP). However, if I open the file with a text editor (e.g. Notepad) and copy the content over…
Patrick
  • 21
  • 3
2
votes
2 answers

How to save .PBM image?

I open a pgm file, convert it to numPy array and change all pixels to 0 or 1 (or 255, I don't know how to proceed yet). How can I save it as .PBM using openCV? Like: P1 512 512 0 1 0 0 0 . . 0 0 0 1 0 . . . . . . . . . . . . . . . . . . . . . . .…
Davi Stuart
  • 269
  • 3
  • 16
1
vote
1 answer

How to read .PBM binary in C

I need to read a .PBM image in binary (p4) for my school project. I tried something like this: for (int i = 0; i < img->height; i++) { for (int x = 0; x < img->width; x++) { c = fgetc(fp); ungetc(c, fp); lum_val =…
1
vote
1 answer

Inverting bits of PBM image while vs for loop

I am trying to flip the color of pixels of a simple pbm image which has only pure black and pure white. I am generating the image myself and then reading it and then flipping the bits and saving both the generated image and the color inverted…
1
vote
1 answer

How to generate a PBM with a combination of 0 & 1 using python

[[0,1,0,1,1,0,0,0,0,1,0,1,0,1,0,1] [0,0,0,0,0,1,1,1,1,0,1,0,1,0,1,1] [0,0,0,0,0,0,1,1,1,1,1,0,1,0,1,0] [0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0] [0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1]] How can I generate a Binary image with the about matrics, in PBM formate?…
jax
  • 3,927
  • 7
  • 41
  • 70
1
vote
1 answer

Generating .pfm image in c++

I have a small program that outputs an rgb image. And I need it to be in .pfm format. So, I have some data in the range [0, 255]. float * data; data = new float[PixelWidth * PixelHeight * 3]; for (int i = 0; i < PixelWidth * PixelHeight * 3; i += 3)…
Denis
  • 719
  • 2
  • 8
  • 23
1
vote
1 answer

I have a PNG image, and wondering how to efficiently convert it to PBM in python

Is there any simple way for converting PNG to PBM? ocrad requires PBM image, not PNG.
Mika Feiler
  • 474
  • 3
  • 17
1
vote
2 answers

Floyd Steinberg Dithering gray(pgm ascii) to black-white (pbm ascii)

I have image in pgm after using this function: void convertWithDithering(array_type& pixelgray) { int oldpixel; int newpixel; int quant_error; for (int y = 0; y< HEIGHT-1; y++){ for (int x = 1; x
0
votes
0 answers

How to read properly binary (raw) .pbm file in C++?

I want to read a binary .pbm file. This is so far what I have: void readPBMFile(const std::string& filePath, std::vector>& pixels) { std::ifstream file(filePath, std::ios::binary); std::string header; std::getline(file,…
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…
0
votes
0 answers

Issue using read() to save pixel info of a pbm file into a 2d array of pixels

This is my struct for a pixel typedef struct pixel{ int couleur[3];//rgb }pixel; so the program takes a .pbm file as input I created a test.pbm file to test my program. This is the content of the test.pbm file. P1 10…
Motcho
  • 3
  • 2
0
votes
2 answers

Image Conversion from PNG to PBM (solely 1s and 0s) using PIL

I am trying to convert PNG images to PBM files. These PNG files are black and white and I need the resulting PBM to be a P1 bitmap which only contains 1s and 0s. So far the closest I have come is the following code: img = Image.open("test part…
0
votes
1 answer

What is difference between export as pbm in RAW and ASCII format?

When I export image as in GIMP it asks wheather to save in ASCII format or in RAW format, what's the difference? size of ASCII is much higher than raw format for same image (3 times higher), why so? I want to see how each pixel values are stored in…
0
votes
1 answer

Convert PNG to PBM P4 with Pillow

I have a PNG image. I can convert it to PBM using Pillow: from PIL import Image im = Image.open("myfig.png") im.save("myfig.pbm") However it seems that encoding P6 is used as default (https://en.wikipedia.org/wiki/Netpbm_format) I would like to…
M.E.
  • 4,955
  • 4
  • 49
  • 128
1
2