Questions tagged [pbm]

pbm - NetPBM bi-level image format

pbm
Filter by
Sorted by
Tagged with
1 vote
2 answers
108 views

Can I ignore a line started with "#" while reading a file in C?

the following code is used to read a .pbm file int **leArquivoImagem(char *nomeImagem, char *tipo, int *lin, int *col) { FILE *arq = fopen(nomeImagem, "r"); if (arq == NULL) { ...
Duartinho Codes's user avatar
0 votes
0 answers
102 views

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<std::vector<int>>& pixels) { std::ifstream file(...
Alexander Jordanov's user avatar
0 votes
2 answers
180 views

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+...
Kornilios Ioannou's user avatar
0 votes
0 answers
35 views

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 ...
Motcho's user avatar
  • 3
0 votes
2 answers
1k views

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 ...
panthers8913's user avatar
1 vote
1 answer
494 views

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++) { ...
Patrik Csikós's user avatar
0 votes
1 answer
763 views

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? ...
GAURABH BHUSHAN's user avatar
0 votes
1 answer
383 views

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....
M.E.'s user avatar
  • 5,193
1 vote
1 answer
292 views

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 ...
Rakesh Sharma's user avatar
1 vote
1 answer
448 views

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 ...
jax's user avatar
  • 4,097
2 votes
1 answer
516 views

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 ...
Patrick's user avatar
  • 21
1 vote
1 answer
488 views

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 (...
Denis's user avatar
  • 759
0 votes
1 answer
99 views

How to make space between every two pixels in a pbm file(ASCII mode)

I have a test.pbm file in ASCII mode containing the code as follows: P1 # Comment 9 9 000000000 011000000 011000000 011000000 011000000 011000010 011111110 011111110 000000000 I want to make a ...
Primo's user avatar
  • 19
-2 votes
1 answer
438 views

JPG to PBM image conversion

I'm trying to convert a ".jpg" file to ".pbm" in java, but I've not been lucky, I tried with the following code: javaxt.io.Image image = new javaxt.io.Image("image.jpg"); image.saveAs("imagepbm.pbm"); ...
KEVINPERCY's user avatar
0 votes
0 answers
93 views

Bit Expansion with finite width (Expanding PBM Images) in C

I am trying to expand a PBM image of say, 5x5 to 10x10 but I have hit somewhat of a road block. I have read the header, and height / width with the following int fSize = size(inFile); char *...
TyrantUT's user avatar
3 votes
1 answer
1k views

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 ...
user avatar
0 votes
1 answer
385 views

C++ Can't open pbm files with Opencv

I'm trying to load a .pbm image with opencv. I'm using the imread function; the documentation says that it should open pbm files but I can't make it work. It does work with other format like png/...
pedro's user avatar
  • 427
1 vote
1 answer
3k views

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

Is there any simple way for converting PNG to PBM? ocrad requires PBM image, not PNG.
Mika Feiler's user avatar
0 votes
0 answers
239 views

Imread for .pbm file

I am trying to read an image, but it gives me errors as such. I have tried to read other formats, which work fine. I could not find much online, so I am posting the question here. Any ideas would be ...
student001's user avatar
1 vote
2 answers
2k views

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; ...
Матвей Козин's user avatar
2 votes
2 answers
4k views

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 ...
Davi Stuart's user avatar
0 votes
1 answer
235 views

.pbm file image render - [vhold] scanline-wiggles?

I'm trying to hack-up a program to read a pbm, pgm, or ppm file and render the image to the postscript output device using the image operator. Just testing the P4 input (binary portable (1-bit) bitmap)...
luser droog's user avatar
  • 19.4k