#include <stdio.h>
#include <stdlib.h>
#include <mymemory.h>
typedef unsigned char BYTE;
void TOUEI1(origin_image, horizon, vertical, size_x, size_y);
void main(argc, argv)
int argc;
char *argv[];
{
char origin_image_file_name[80];
char projection_x_file_name[80];
char projection_y_file_name[80];
int i,j;
int IMAGE_SIZE_ROW, IMAGE_SIZE_COL;
BYTE **origin_image;
BYTE *buff;
unsigned int *horizon;
unsigned int *vertical;
FILE *I_file, *projection_x, *projection_y;
FILE *xfile, *yfile;
/*
prompt user to input arguments.
*/
printf("origin_image_file_name : ");
scanf("%s", origin_image_file_name);
printf("No. of image column : ");
scanf("%d",&IMAGE_SIZE_COL);
printf("No. of image line : ");
scanf("%d",&IMAGE_SIZE_ROW);
printf("projection_x_file_name : ");
scanf("%s", projection_x_file_name);
printf("projection_y_file_name : ");
scanf("%s", projection_y_file_name);
/*
read image file from disk to memory
*/
if((I_file=fopen(origin_image_file_name, "rb")) == NULL)
{
printf("file open error!");
exit(-1);
}
if((projection_x=fopen(projection_x_file_name, "wb")) == NULL)
{
printf("file open error!");
exit(-1);
}
if((projection_y=fopen(projection_y_file_name, "wb")) == NULL)
{
printf("file open error!");
exit(-1);
}
xfile = fopen("x.dat", "wt");
yfile = fopen("y.dat", "wt");
/*
MEMORY ALLOCATION
*/
origin_image = bmatrix(IMAGE_SIZE_ROW, IMAGE_SIZE_COL);
buff = bvector(IMAGE_SIZE_COL);
horizon = uivector(IMAGE_SIZE_ROW);
vertical = uivector(IMAGE_SIZE_COL);
/*
IMAGE READING
*/
for(i=0;i<IMAGE_SIZE_ROW;i++)
{
fread(buff, sizeof(BYTE), IMAGE_SIZE_COL, I_file);
for(j=0;j<IMAGE_SIZE_COL;j++)
origin_image[i][j] = buff[j];
}
fclose(I_file);
/*
calculate projection
*/
TOUEI1(origin_image, horizon, vertical, IMAGE_SIZE_ROW, IMAGE_SIZE_COL);
/*
saving text file
*/
for(i=0;i<IMAGE_SIZE_ROW;i++)
{
fprintf(xfile, "%d\n", horizon[i]);
}
for(i=0;i<IMAGE_SIZE_COL;i++)
{
fprintf(yfile, "%d\n", vertical[i]);
}
/*
saving projection file
*/
fwrite(horizon, sizeof(unsigned int), IMAGE_SIZE_ROW, projection_x);
fwrite(vertical, sizeof(unsigned int), IMAGE_SIZE_COL, projection_y);
free_bmatrix(origin_image,IMAGE_SIZE_ROW, IMAGE_SIZE_COL);
free_bvector(buff);
free_uivector(horizon);
free_uivector(vertical);
fclose(projection_x);
fclose(projection_y);
}
void TOUEI1(origin_image, horizon, vertical, size_x, size_y)
/*
purpose: x,y direction projection
arguments:
h : horizon projection
v : vertical projection
*/
BYTE **origin_image;
unsigned int *horizon;
unsigned int *vertical;
int size_x, size_y;
{
int i, j;
/*
calculate horizon projection
*/
for(i=0;i<size_x;i++)
{
horizon[i]=0;
for(j=0;j<size_y;j++)
{
horizon[i] += origin_image[i][j];
}
}
/*
calculate vertical projection
*/
for(j=0;j<size_y;j++)
{
vertical[j]=0;
for(i=0;i<size_x;i++)
{
vertical[j] += origin_image[i][j];
}
}
}
간단한 주석좀 부탁드립니다. 이미지 프로세싱하는 프로그램이라는건 알겠는데 두개의 이미지를 하나로 합치는 것 맞나요? 아...헤더파일인 mymemory.h 가 없어서 골치 아프니다..
아니면 이게 대충 모하는 프로그램이다 라는 것만 알려주세요 ㅠ
|