Click here to Skip to main content
15,905,004 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey friends
please i work with visual studio c language ,
i want know how i can read image line by line (input image like a file in c)
for example image 512*512
read 512 line by line and every line save it in one file :)
thnx :)

What I have tried:

i nothing tried i want just a idea
Posted
Updated 7-Jun-16 7:42am
Comments
barneyman 6-Jun-16 19:56pm    
depends on the format of the image
yagami_md 6-Jun-16 21:23pm    
I have .pgm image ( a greyscale image)
[no name] 6-Jun-16 22:23pm    
Why not do a little research on Google. This should be the first step and will save you lots of time: https://www.google.com.au/?gfe_rd=cr&ei=dE-dVP_DAauT8QfZzIGgBg&gws_rd=ssl#q=read+pgm+line+by+line

1 solution

That isnt much. If you only want to read the bytes than you can use the file i/o and read your 512 bytes.

But interesting gets the display of that data. Than you must access the pixels correctly. Normally the x-axis is a line and the y-axis is the line count. Prepare a big enough picture at first and than loop and set the pixels.

The CXImage article is an outstanding piece which demonstrates a hole bunch of the needed technology.
 
Share this answer
 
Comments
yagami_md 7-Jun-16 5:38am    
P2# This is an example called j.pgm
6 5
255
0 0 0 0 255 70
0 0 0 0 255 50
0 0 0 0 255 200
0 0 0 0 100 10

Line 1 - The version
Line 2 - The comment
Line 3 - The width and height
Line 4 - The gray level
Line 5 to end - The pixels.


this is what I want , exactly ..this is the ody general f pgm image , I want get the the widh and the heigh of the image (this is line 3)...after I ant read th iage file line by line
yagami_md 7-Jun-16 14:21pm    
I have over loading now :/ I tried to work with pbm format , I lern that pbm format have to color 0 or 1 white or black , the first I convert the image pgm to pbm I seen it's oki the image change to white and black but if I tried o see all pixel the result its different :/ I seen more value of pixel no ust 0 or 1 :/
// read_image_line_by_line.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdio.h>
#include<conio.h>
void func()
{
FILE *pFile;
pFile = fopen("lena512.pbm", "rb");
int c;
do {
c = getc (pFile);
printf("%d \n",c);
} while (c != EOF);
fclose (pFile);

fclose(pFile);

}


int _tmain(int argc, _TCHAR* argv[])
{
func();

getch();

}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900