📄 cips6.c
字号:
************************************************/
printf("\nReading image");
read_tiff_image(image_name, image1, il, ie, ll, le);
printf("\nReading image");
read_tiff_image(image_name, image2,
il, ie+100, ll, le+100);
/**********************************************
*
* If show_hist is 1 OR do hist equalization
* then zero the histogram and
* calculate it for the two image arrays.
*
***********************************************/
if( (show_hist == 1) ||
(color_transform[0] == 'H')){
zero_histogram(histogram);
zero_histogram(final_hist);
printf("\nDJET> Calculating histograms");
calculate_histogram(image1, histogram);
calculate_histogram(image2, histogram);
}
/*********************************************
*
* Alter the images to 64 gray shades.
* Either do it with straight multiply
* and divide or use hist equalization.
*
* If using hist equalization then you must
* also read and calculate the hist for
* the other two image arrays that will be
* printed.
*
**********************************************/
if(color_transform[0] == 'S'){
if(image_colors == 256){
for(i=0; i<ROWS; i++){
for(j=0; j<COLS; j++){
image1[i][j] = image1[i][j]/4;
image2[i][j] = image2[i][j]/4;
}
}
} /* ends if image_colors == 256 */
if(image_colors == 16){
for(i=0; i<ROWS; i++){
for(j=0; j<COLS; j++){
image1[i][j] = image1[i][j]*4;
image2[i][j] = image2[i][j]*4;
}
}
} /* ends if image_colors == 16 */
} /* ends if color_transform == S */
if(color_transform[0] == 'H'){
printf("\nReading image");
read_tiff_image(image_name, image1,
il+100, ie, ll+100, le);
printf("\nReading image");
read_tiff_image(image_name, image2,
il+100, ie+100, ll+100, le+100);
printf("\nDJET> Calculating histograms");
calculate_histogram(image1, histogram);
calculate_histogram(image2, histogram);
printf("\nReading image");
read_tiff_image(image_name, image1,
il, ie, ll, le);
printf("\nReading image");
read_tiff_image(image_name, image2,
il, ie+100, ll, le+100);
printf("\nDJET> Equalizing histogram");
perform_histogram_equalization(image1, histogram,
64.0, 40000.0);
printf("\nDJET> Equalizing histogram");
perform_histogram_equalization(image2, histogram,
64.0, 40000.0);
printf("\nDJET> Calculating histograms");
calculate_histogram(image1, final_hist);
calculate_histogram(image2, final_hist);
} /* ends if color_transform == H */
/*********************************************
*
* If invert is set them invert the
* transformed image arrays (they now
* only have 64 shades of gray).
*
**********************************************/
if(invert == 1){
for(i=0; i<ROWS; i++){
for(j=0; j<COLS; j++){
image1[i][j] = 63 - image1[i][j];
image2[i][j] = 63 - image2[i][j];
}
}
}
/********************************************
*
* Now set the graphics mode on the printer
*
*********************************************/
printf("\nBegin");
end_graphics_mode(printer);
select_300_dpi_resolution(printer);
set_raster_width(printer);
start_raster_graphics(printer);
select_full_graphics_mode(printer);
/*********************************************
*
* Print the two arrays to make a 100x200
* output. To do this you loop over 100 rows,
* set the r buffer to the image values, set
* the graphics, and print the row via
* function print_original_200_row.
*
**********************************************/
for(i=0; i<100; i++){
for(j=0; j<100; j++){
r[j] = image1[i][j];
r[j+100] = image2[i][j];
} /* ends loop over j */
end_graphics_mode(printer);
select_300_dpi_resolution(printer);
set_raster_width(printer);
start_raster_graphics(printer);
select_full_graphics_mode(printer);
print_original_200_row(printer, r);
printf("\n\tPrinting row %d", i);
} /* ends loop over i */
/* ends first half */
/**********************************************
*
* In order to print 200x200 repeat
* the above steps for 2 more 100x100 arrays
*
***********************************************/
printf("\nReading image");
read_tiff_image(image_name, image1,
il+100, ie, ll+100, le);
printf("\nReading image");
read_tiff_image(image_name, image2,
il+100, ie+100, ll+100, le+100);
/*********************************************
*
* Alter the images to 64 shades of gray.
*
* Either do it with straight multiply
* and divide or use hist equalization.
*
**********************************************/
if(color_transform[0] == 'S'){
if(image_colors == 256){
for(i=0; i<ROWS; i++){
for(j=0; j<COLS; j++){
image1[i][j] = image1[i][j]/4;
image2[i][j] = image2[i][j]/4;
}
}
} /* ends if image_colors == 256 */
if(image_colors == 16){
for(i=0; i<ROWS; i++){
for(j=0; j<COLS; j++){
image1[i][j] = image1[i][j]*4;
image2[i][j] = image2[i][j]*4;
}
}
} /* ends if image_colors == 16 */
} /* ends if color_transform == S */
if(color_transform[0] == 'H'){
printf("\nDJET> Equalizing histogram");
perform_histogram_equalization(image1, histogram,
64.0, 40000.0);
printf("\nDJET> Equalizing histogram");
perform_histogram_equalization(image2, histogram,
64.0, 40000.0);
printf("\nDJET> Calculating histograms");
calculate_histogram(image1, final_hist);
calculate_histogram(image2, final_hist);
} /* ends if color_transform == S */
/************************************************
*
* If invert is set them invert the transformed
* image arrays (they now only have 64 shades
* of gray).
*
*************************************************/
if(invert == 1){
for(i=0; i<ROWS; i++){
for(j=0; j<COLS; j++){
image1[i][j] = 63 - image1[i][j];
image2[i][j] = 63 - image2[i][j];
}
}
}
printf("\nBegin");
end_graphics_mode(printer);
select_300_dpi_resolution(printer);
set_raster_width(printer);
start_raster_graphics(printer);
select_full_graphics_mode(printer);
/***********************************************
*
* Print the two arrays to make a 100x200 output.
* To do this you loop over 100 rows, set the
* r buffer to the image values, set the
* graphics, and print the row via function
* print_original_200_row.
*
*************************************************/
for(i=0; i<100; i++){
for(j=0; j<100; j++){
r[j] = image1[i][j];
r[j+100] = image2[i][j];
} /* ends loop over j */
end_graphics_mode(printer);
select_300_dpi_resolution(printer);
set_raster_width(printer);
start_raster_graphics(printer);
select_full_graphics_mode(printer);
print_original_200_row(printer, r);
printf("\n\tPrinting row %d", i);
} /* ends loop over i */
/**********************************************
*
* If show_hist is 1 then calculate the
* histogram for the two image arrays and
* print the histogram.
*
***********************************************/
if(show_hist == 1){
if(color_transform[0] == 'S'){
calculate_histogram(image1, histogram);
calculate_histogram(image2, histogram);
print_hist_image(printer, histogram);
}
if(color_transform[0] == 'H'){
print_hist_image(printer, final_hist);
}
}
/*********************************************
*
* Print a couple of blank lines then print
* the caption.
*
**********************************************/
end_graphics_mode(printer);
strcpy(page, " \n");
fputs(page, printer);
fputs(page, printer);
sprintf(page, " %s\n", caption);
fputs(page, printer);
fputc(FORMFEED, printer);
fclose(printer);
printf("\nEnd");
} /* ends print_graphics_image */
/******************************************
*
* get_graphics_caption(...
*
******************************************/
get_graphics_caption(caption)
char caption[];
{
printf("\nEnter the caption to be printed\n---");
gets(caption);
} /* ends get_graphics_caption */
/************************************************
*
* select_full_graphics_mode(...
*
************************************************/
select_full_graphics_mode(printer)
FILE *printer;
{
fputc(ESCAPE, printer);
fputc('*', printer);
fputc('b', printer);
fputc('0', printer);
fputc('M', printer);
}
/************************************************
*
* set_horizontal_offset(...
*
************************************************/
set_horizontal_offset(printer)
FILE *printer;
{
fputc(ESCAPE, printer);
fputc('*', printer);
fputc('b', printer);
fputc('4', printer);
fputc('9', printer);
fputc('6', printer);
fputc('X', printer);
}
/************************************************
*
* set_shorter_horizontal_offset(...
*
************************************************/
set_shorter_horizontal_offset(printer)
FILE *printer;
{
fputc(ESCAPE, printer);
fputc('*', printer);
fputc('b', printer);
fputc('4', printer);
fputc('8', printer);
fputc('0', printer);
fputc('X', printer);
}
/************************************************
*
* end_graphics_mode(...
*
************************************************/
end_graphics_mode(printer)
FILE *printer;
{
fputc(ESCAPE, printer);
fputc('*', printer);
fputc('r', printer);
fputc('B', printer);
}
/************************************************
*
* set_raster_width(...
*
************************************************/
set_raster_width(printer)
FILE *printer;
{
fputc(ESCAPE, printer);
fputc('*', printer);
fputc('r', printer);
fputc('2', printer);
fputc('2', printer);
fputc('0', printer);
fputc('0', printer);
fputc('S', printer);
}
/************************************************
*
* start_raster_graphics(...
*
************************************************/
start_raster_graphics(printer)
FILE *printer;
{
fputc(ESCAPE, printer);
fputc('*', printer);
fputc('r', printer);
fputc('0', printer);
fputc('A', printer);
}
/************************************************
*
* select_300_dpi_resolution(...
*
************************************************/
select_300_dpi_resolution(printer)
FILE *printer;
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -