The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
image in 2d char array
Discuss image in 2d char array in the C Programming forum on Dev Shed. image in 2d char array C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 4th, 2004, 08:22 AM
|
|
Contributing User
|
|
Join Date: Nov 2004
Posts: 79
Time spent in forums: 6 h 30 m 8 sec
Reputation Power: 9
|
|
|
image in 2d char array
i have an 256x256 grayscale image in .dat format.
i am reading the file in turbo C in an 2d char array and comparing with another similar picture to check if they are the same..
and i am doing some enhancement of the original image,
and to view the enhanced image, am changing .dat to .raw format and viewing in adobe photoshop.
well is this process right?
in the sense that getting an gray scale image in 2d char array.
will it be exactly reproduced.
will the 2d char array handle a gray scale image?
thats my doubt..
and can the complex operations like filtering and transforms done on images represented by array elements.. 
|

November 4th, 2004, 08:42 AM
|
 |
Lord of Dorkness
|
|
Join Date: Jan 2004
Location: Central New York. Texan via Arizona, out of his element!
|
|
|
One can represent 256 shades of gray in an 8-bit unsigned char. For more information regarding reading, converting, manipulating, filtering, and so forth, be sure and search the forums. Everyone and two of his/her ex-spouses are working on iris-imaging these days.
__________________
Functionality rules and clarity matters; if you can work a little elegance in there, you're stylin'.
If you can't spell "u", "ur", and "ne1", why would I hire you? 300 baud modem? Forget I mentioned it.
DaWei on Pointers Politically Incorrect.
|

November 4th, 2004, 10:52 PM
|
|
Contributing User
|
|
Join Date: Feb 2004
Location: San Francisco Bay
|
|
|
If every bit of the file (I mean every binary digit) is stored (in a 2d char array or otherwise), then it is exactly represented. Otherwise, it depends on the process used to convert the file into the data stored in your program.
|

November 5th, 2004, 12:31 AM
|
|
Contributing User
|
|
Join Date: Nov 2004
Posts: 79
Time spent in forums: 6 h 30 m 8 sec
Reputation Power: 9
|
|
|
this is my code to read two images and match them to check the similarity..
i want to view the .dat image file, so i convert it to .raw and view them in photoshop..
is there any other way of doing it..
but above all is this process right???
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <conio.h>
#include <alloc.h>
void main( )
{
FILE *fp,*fp1,*fp2,*fp3;
unsigned char i[100][100],j[100][100];
int m,n;
clrscr();
/* open the input print that has to be matched */
if((fp = fopen("f16.dat","r+")) == 0)
{
printf("Unable to open the specified file.\n");
getch();
exit(1);
}
else
{
for(m=0;m<100;m++)
{
for(n=0;n<100;n++)
{
fscanf(fp,"%c",&i[m][n]);
}
}
fclose(fp);
/* convert the .dat file to .raw file for viewing the image */
fp2=fopen("f16raw.raw","w");
//if(fs!=0) printf("destination file open is successful\n");
//getch();
for(m=0;m<100;m++)
{
for(n=0;n<100;n++)
{
fprintf(fp2,"%c",i[m][n]);
}
//fprintf(fp2,"\n");
}
fclose(fp2);
/* open the print that has to be compred with the input print */
if((fp3 = fopen("f16_01.dat","r")) == 0)
{
printf("Unable to open the file to be compared with.\n");
getch();
exit(1);
}
for(m=0;m<100;m++)
{
for(n=0;n<100;n++)
{
fscanf(fp3,"%c",&j[m][n]);
// printf("%d",i[m][n]);
}
}
fclose(fp3);
/* now the comparison between the two prints */
for(m=0;m<100;m++)
{
for(n=0;n<100;n++)
{
if((i[m][n])!=(j[m][n]))
{
count=count+1;
}
}
}
/* display the results of the comparison process */
printf("***** Pixel to Pixel comparison of the two prints *****\n\n");
if(count>100)
{
printf("The two prints dont match\n\n");
printf("And the mismatch points add up to %d\n",count);
}
else
{
printf("The two prints match\n\n");
printf("And the mismatch points add up to %d\n",count);
}
}
getch();
}
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|