&^%$#@!
14
Wed Apr 05 05:51:03 1995
This has the redundant pattern_index removed and the
code works.
!@#$%^&
/***********************************************
*
* file cstereo.c
*
* Functions: This file contains
* main
* fill_line
* initialize_pattern
* lengthen_pattern
* no_change
* shorten_pattern
* get_random_values
* random_substitution
* test_print_line
*
* Purpose:
* This file contains a program that will
* make character based stereograms.
*
* External Calls:
* none
*
* Modifications:
* 7 February 1995 - created
*
*************************************************/
/***** ALGORITHM NOTES
width is the width of the input and output lines
pattern_width is the initial width of the pattern
current_width is the current width of the pattern
(this changes as elements are inserted into
and deleted from the pattern).
pattern[] must be wider than width and narrower than
? so I will try it at width=width
depth_line[] will be width wide
processed_pattern will be width wide
index points to the current place in the pattern
we are working on
pp_index points to the current place in the processed
pattern, Cannot use the depth_line counter j
for this because you will skip over places in
the processed pattern.
*********/
#include "cips.h"
#define PATTERN_START 48 /* the zero character */
#define PATTERN_END 122 /* the small z character */
#define KONSTANT 2
#define ASCII_SIZE 256
#define TEST_NO_CHANGE
#undef DEBUG_MODE
#define COMMAND_LINE_MODE
void fill_line();
void initialize_pattern();
void lengthen_pattern();
void no_change();
void shorten_pattern();
void get_random_values();
void random_substitution();
void test_print_line();
main(argc, argv)
char *argv[];
int argc;
{
char *depth_line,
*pattern,
*processed_pattern,
*pdest,
response[80];
char last_character,
this_character;
FILE *depth_file,
*processed_pattern_file,
*stereo_file;
int current_width,
j,
index,
location,
max_width,
pattern_width,
pp_index,
width;
#ifdef COMMAND_LINE_MODE
if(argc != 6){
printf(
"\nusage: cstereo pattern-width width-of-line"
"\n depth-file-name "
"stereo-file-name "
"\n processed-pattern-file-name"
"\n");
exit(1);
}
pattern_width = atoi(argv[1]);
width = atoi(argv[2]);
pattern = malloc(KONSTANT*width);
depth_line = malloc(KONSTANT*width);
processed_pattern = malloc(KONSTANT*width);
if((depth_file = fopen(argv[3], "rt")) == NULL){
printf(
"\ncstereo: Error opening input file %s\n",
argv[3]);
exit(3);
}
if((stereo_file = fopen(argv[4], "wt")) == NULL){
printf(
"\ncstereo: Error opening output file %s\n",
argv[4]);
exit(4);
}
if((processed_pattern_file =
fopen(argv[5], "wt")) == NULL){
printf(
"\ncstereo: Error opening temp file %s\n", argv[5]);
exit(5);
}
#endif /* ifdef COMMAND_LINE_MODE */
#ifdef DEBUG_MODE
pattern_width = 10;
width = 60;
pattern = malloc(KONSTANT*width);
depth_line = malloc(KONSTANT*width);
processed_pattern = malloc(KONSTANT*width);
if((depth_file = fopen("dfile.txt", "rt")) == NULL){
printf(
"\ncstereo: Error opening input file %s\n",
"dfile.txt");
exit(3);
}
if((stereo_file = fopen("sfile.txt", "wt")) == NULL){
printf(
"\ncstereo: Error opening output file %s\n",
"sfile.txt");
exit(4);
}
if((processed_pattern_file =
fopen("ppfile.txt", "wt")) == NULL){
printf(
"\ncstereo: Error opening temp file %s\n", "ppfile.txt");
exit(5);
}
#endif /* ifdef DEBUG_MODE */
/***********************************************
*
* This is the major loop of the program.
* It reads one line at a time from the
* depth file, processes that one line,
* and writes the resulting pattern to the
* processed pattern file.
*
***********************************************/
while(fgets(depth_line, KONSTANT*width, depth_file)){
fill_line(pattern, KONSTANT*width);
fill_line(processed_pattern, KONSTANT*width);
initialize_pattern(pattern,
¤t_width,
&max_width,
pattern_width,
&index);
/*******************************************
*
* Loop through the characters in the
* depth_line. Call one of the three
* processing routines based on the
* relationship between the last character
* and this character.
*
*******************************************/
last_character = depth_line[0];
pp_index = 0;
for(j=0; j<width; j++){
this_character = depth_line[j];
if(this_character == '\n')
this_character = last_character;
if(this_character > last_character)
shorten_pattern(
(this_character-last_character),
pattern, &index, ¤t_width,
width);
if(this_character < last_character)
lengthen_pattern(
(last_character-this_character),
pattern, &index, ¤t_width,
&width, &max_width);
/****************************************
*
* Perform the no_change in every
* pass. Do it after you have done
* the shorten and lenghten pattern.
*
****************************************/
no_change(pattern, processed_pattern,
pp_index, current_width, &index);
pp_index++;
last_character = depth_line[j];
} /* ends loop over j */
pdest = strchr(processed_pattern, '\0');
location = pdest - processed_pattern;
processed_pattern[location] = '\n';
fputs(processed_pattern, processed_pattern_file);
random_substitution(processed_pattern, width);
fputs(processed_pattern, stereo_file);
} /* ends the major loop */
fclose(depth_file);
fclose(processed_pattern_file);
fclose(stereo_file);
free(pattern);
free(depth_line);
free(processed_pattern);
return(111);
} /* ends main */
/***********************************************
*
* shorten_pattern(...
*
* This funtion shortens the pattern by
* deleting an element from it. For example,
* if the input pattern is abcdefg,
* the output pattern could be abcfg.
*
***********************************************/
void shorten_pattern(size, pattern, index,
current_width, width)
char *pattern;
int size, *index, *current_width, width;
{
char *temp_pattern;
int i, new_index, new_width;
temp_pattern = malloc(KONSTANT*width);
for(i=0; i<width; i++)
temp_pattern[i] = pattern[i];
fill_line(pattern, width);
new_index = 0;
new_width = *current_width - size;
/*********************************************
*
* Increase the index by the amount we want
* to shorten the pattern. Then copy the
* temp_pattern ba
没有合适的资源?快使用搜索试试~ 我知道了~
图像处理C语言源代码(Source Code of Image Processing in C)
共213个文件
c:210个
makegcc:1个
h:1个
4星 · 超过85%的资源 需积分: 11 101 下载量 98 浏览量
2011-05-22
10:00:06
上传
评论 3
收藏 530KB ZIP 举报
温馨提示
图像处理C语言源代码(Source Code of Image Processing in C)
资源推荐
资源详情
资源评论
收起资源包目录
图像处理C语言源代码(Source Code of Image Processing in C) (213个子文件)
VCSTEREO.C 189KB
VPSTEREO.C 176KB
VSCSTERE.C 120KB
CIPS7.C 120KB
TRAVEL15.C 97KB
TRAVEL.C 97KB
TRAVEL14.C 95KB
VSPSTERE.C 93KB
CIPS6.C 74KB
imageio.c 66KB
SEGMENTS.C 62KB
MORPH.C 58KB
BACKPROP.C 48KB
CIPS5.C 43KB
DELAS.C 42KB
CIPS4.C 41KB
CIPS.C 37KB
TIFFS.C 37KB
SKELETON.C 36KB
EDGES.C 34KB
kf.c 32KB
bigc.c 29KB
testbmp.c 27KB
brwtiff.c 27KB
LZW.C 26KB
text.c 25KB
ILABEL.C 25KB
DJET.C 24KB
XDISPLAY.C 23KB
SEGMENT2.C 23KB
SEGMENT.C 23KB
stuff.c 22KB
TXTRSUBS.C 21KB
CGROW.C 20KB
WTIFF.C 20KB
PAGEIT.C 20KB
PATTERN.C 20KB
DESKJET.C 19KB
DPDETEX.C 19KB
TOC.C 18KB
DISPTEST.C 18KB
DISPLAY.C 18KB
PSTEREO.C 18KB
USAGE.C 18KB
DUMMY.C 17KB
FITT.C 17KB
SCALE.C 17KB
XSPS.C 17KB
SAVELZWC.C 17KB
ED.C 16KB
LZWC.C 16KB
bmpedge.c 16KB
EMBSUBS.C 15KB
HT.C 15KB
WARPSUBS.C 15KB
XPSTEREO.C 14KB
EDGE.C 14KB
CSTEREO.C 14KB
SPSTEREO.C 14KB
stega.c 14KB
CIPS3.C 14KB
LZWDC.C 14KB
SEGMENT4.C 13KB
SCSTEREO.C 13KB
FILT2.C 13KB
DFTSAVE.C 13KB
TESTVGA.C 12KB
d.c 12KB
DFT.C 12KB
XCSTEREO.C 12KB
GEOSUBS.C 12KB
MAIN3SEG.C 12KB
TCOMMSUB.C 12KB
lambert.c 12KB
para.c 12KB
XSCS.C 12KB
EDGE2.C 11KB
FILTER.C 11KB
uc.c 11KB
TIFF.C 10KB
B.C 9KB
EMBOSS.C 9KB
ALPL.C 9KB
MAINSK.C 8KB
CIPS2.C 8KB
SEGMENT3.C 8KB
header.c 7KB
XTRA.C 7KB
PI.C 7KB
PMRCS.C 7KB
BOOLE.C 7KB
ADALINE.C 7KB
flip.c 6KB
xemboss.c 6KB
RTIFF.C 6KB
SIDE.C 6KB
ROTATE.C 6KB
MADALINE.C 6KB
medge.c 6KB
EDGE3.C 5KB
共 213 条
- 1
- 2
- 3
hit_gjj
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页