Connecting Tech Pros Worldwide Forums | Help | Site Map

Image Read and Display

Member
 
Join Date: Mar 2007
Posts: 79
#1: Mar 13 '07
I am a newbie.

In MSVC++ 2005, how can I read in an image (say binary or even grayscale/color) and then display it in a window after some image processing?? I know something like MFC can ease the task.I also know something like image buffer and array. Which one is better? How to implement?

I really have no idea, even I have read a lot of materials. Please help!! Give me some instruction! Thanks!!
Newbie
 
Join Date: Mar 2007
Posts: 3
#2: Mar 14 '07

re: Image Read and Display


suppose ur file name is spect.dat. first we study that image in program as follows
int *p;
p = sizeof(int) malloc(sizeof(int)*128*128*120);
FILE *INPUT,*OUTPUT;
INPUT = fopen("spect.dat","rb");
OUTPUT = fopen("spectoutput.dat","wb");
fread(p,sizeof(int)*1,1,INPUT);
fwrite(p,sizeof(int)*1,1,OUTPUT);

description;
line 2; suppose our image is 128*128 with 120 projection, the we allocate memory space for that.
line 5;
we read the image from spect.dat file and it stored in p.

line 6; we see the same image in program. ie., our input image in our programme. From p we read that image and stored in OUTPUT ie., we see the image in the spectoutput.dat.
wb- write binary from pointer.
rb - read binary from outside file.
Newbie
 
Join Date: Mar 2007
Posts: 3
#3: Mar 14 '07

re: Image Read and Display


are u know about how to convert 3D pointer to 1D pointer. Please send reply.
saranjegan's Avatar
Member
 
Join Date: Feb 2007
Location: India
Posts: 51
#4: Mar 14 '07

re: Image Read and Display


Quote:

Originally Posted by kenneth6

I am a newbie.

In MSVC++ 2005, how can I read in an image (say binary or even grayscale/color) and then display it in a window after some image processing?? I know something like MFC can ease the task.I also know something like image buffer and array. Which one is better? How to implement?

I really have no idea, even I have read a lot of materials. Please help!! Give me some instruction! Thanks!!


whats the type of image you are to open it may differ respect to types
Member
 
Join Date: Mar 2007
Posts: 79
#5: Mar 14 '07

re: Image Read and Display


Quote:

Originally Posted by shankarshanmugam

are u know about how to convert 3D pointer to 1D pointer. Please send reply.

1. For the codes about fread, fopen and fwrite, to make it executable in MSVC++, should I place it inside a cpp file like this and put the bat file under the same folder of cpp file? I failed to do that in MSVC++.

#include <stdio.h>
using namespace std;
int main () {
// the block of codes you mentioned
}

2. I am quite confused of what template I should choose in New Project in such occasion? MFC Application or Win32 Project?

3. Do you mean the 2D array assignment like this?

#define WIDTH 5
#define HEIGHT 3

int Tommy [HEIGHT][WIDTH];
int n,m;

int main ()
{
for (n=0;n<HEIGHT;n++)
for (m=0;m<WIDTH;m++)
{
jimmy[n][m]=(n+1)*(m+1);
}
return 0;
}


Quote:

Originally Posted by saranjegan

whats the type of image you are to open it may differ respect to types

Actually, what I am doing is to read in a binary image file, say jpg, bmp, etc. for later processing. Or simply a file created by notepad filled with 1 & 0.
Member
 
Join Date: Mar 2007
Posts: 79
#6: Mar 15 '07

re: Image Read and Display


I have no previous programming experience, no formal teaching materials received and no teacher's guidance. But I have to do all that on my own. Everything I can do is to research on my own. Please give me some instruction. I get lost and have a big difficulty in such conceptual level.

Help ! Please !
saranjegan's Avatar
Member
 
Join Date: Feb 2007
Location: India
Posts: 51
#7: Mar 15 '07

re: Image Read and Display


Quote:

Originally Posted by kenneth6

I have no previous programming experience, no formal teaching materials received and no teacher's guidance. But I have to do all that on my own. Everything I can do is to research on my own. Please give me some instruction. I get lost and have a big difficulty in such conceptual level.

Help ! Please !




1.Select the format of file which you are about to open and read

2.if you select BMP format of files it may be easy for you to work with that
( first study the format of the bmp file google with bmp file struct u may get some tutorials)

3.Study the format of bmp file it has header information for first 14 bytes read them using fread function and put in a struct or array

3.secondly it has header file info for the next 40 bytes you read that too and have it

4.now you can play with the image with these details .it will be more easy if you are working in VC++ there are lot of function for this look for msdn libraries
use SetDIBitsToDevice function
you can try by yours
Newbie
 
Join Date: Mar 2007
Posts: 1
#8: Mar 24 '07

re: Image Read and Display


Hello All,

Can any one tell me how to open a 2 - bit binary Image file in C after getting both the file and info headers and the colormap. The problem is with reading the pixel data using fgetc( ). This function reads one byte at a time from the file and since a 32 x 32 binary image has 1024 pixels, each represented by 2 bits, the function perhaps produces a mismatch between the amount of data being read and the data present in the file. How to resolve this problem.

Anurag Mishra


Quote:

Originally Posted by kenneth6

I am a newbie.

In MSVC++ 2005, how can I read in an image (say binary or even grayscale/color) and then display it in a window after some image processing?? I know something like MFC can ease the task.I also know something like image buffer and array. Which one is better? How to implement?

I really have no idea, even I have read a lot of materials. Please help!! Give me some instruction! Thanks!!

Reply