C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 4th, 2004, 08:22 AM
dalaharp dalaharp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 79 dalaharp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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..

Reply With Quote
  #2  
Old November 4th, 2004, 08:42 AM
DaWei_M's Avatar
DaWei_M DaWei_M is offline
Lord of Dorkness
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Jan 2004
Location: Central New York. Texan via Arizona, out of his element!
Posts: 8,515 DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level) 
Time spent in forums: 4 Weeks 18 h 59 m 31 sec
Warnings Level: 20
Number of bans: 3
Reputation Power: 3268
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.

Reply With Quote
  #3  
Old November 4th, 2004, 10:52 PM
Lux Perpetua Lux Perpetua is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2004
Location: San Francisco Bay
Posts: 1,938 Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 2 h 43 m 16 sec
Reputation Power: 1312
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.

Reply With Quote
  #4  
Old November 5th, 2004, 12:31 AM
dalaharp dalaharp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 79 dalaharp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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();
}

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > image in 2d char array

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap