F.4. CODELISTINGSFORCHAPTER4
409
strcat(line, "\n");
fputs(line, out_file);
for(i=0; i<height; i++){
sprintf(line, "%5d>", i);
for(j=0; j<width; j++){
if(the_image[i][j] == 0)
strcat(line, " ");
else
strcat(line, "*");
}
strcat(line, "\n");
fputs(line, out_file);
}
free_image_array(the_image, height);
fclose(out_file);
} /* * ends main */
Listing3.3-ThedumpbProgram
F.4 CodeListingsforChapter4
/**************************************************
*
*
file hist.c
*
*
Functions: This file contains
*
calculate_histogram
*
perform_histogram_equalization
*
zero_histogram
*
smooth_histogram
*
*
Purpose: These functions calculate
*
the histogram of an input image e array.
*
They also modify an image by equalizing
*
its histogram.
*
*
Modifications:
How to convert pdf file to powerpoint presentation - C# Create PDF from PowerPoint Library to convert pptx, ppt to PDF in C#.net, ASP.NET MVC, WinForms, WPF
Online C# Tutorial for Creating PDF from Microsoft PowerPoint Presentation
table from pdf to powerpoint; convert pdf file into ppt
How to convert pdf file to powerpoint presentation - VB.NET Create PDF from PowerPoint Library to convert pptx, ppt to PDF in vb.net, ASP.NET MVC, WinForms, WPF
VB.NET Tutorial for Export PDF file from Microsoft Office PowerPoint
convert pdf to powerpoint presentation; drag and drop pdf into powerpoint
410
APPENDIXF. SOURCECODELISTINGS
*
July 86 - ported to IBM-PC
*
August 1990 - modified d for r use in the
*
C Image Processing g System
*
March 1992 - removed the hardwired values
*
of 100 and replaced them with ROWS
*
and COLS. . There e are still some
*
hardwired numbers s in n this file, but
*
they deal with displaying a histogram.
*
October 4, 1992 - added the smooth histogram
*
function.
*
April 22, 1998 - modified routines to work
*
with an entire image in one array.
*
**************************************************/
#include "cips.h"
#define PRINT_WIDTH H 80
#define FORMFEED
’\014’
/*****************************************
*
*
zero_histogram(...
*
*
This function clears s or r zeros a
*
histogram array.
*
******************************************/
zero_histogram(histogram, gray_levels)
int
gray_levels;
unsigned long histogram[];
{
int i;
for(i=0; i<gray_levels; i++)
histogram[i] = 0;
} /* * ends zero_histogram */
/*****************************************
VB.NET PowerPoint: Use PowerPoint SDK to Create, Load and Save PPT
NET method and sample code in this part will teach you how to create a fully customized blank PowerPoint file by using the smart PowerPoint presentation control
convert pdf file to powerpoint; how to convert pdf into powerpoint presentation
C# PDF Text Extract Library: extract text content from PDF file in
But sometimes, we need to extract or fetch text content from source PDF document file for word processing, presentation and desktop publishing applications.
online pdf converter to powerpoint; change pdf to powerpoint online
F.4. CODELISTINGSFORCHAPTER4
411
*
*
calculate_histogram(...
*
*
This function calculates the histogram
*
for an input image array.
*
******************************************/
calculate_histogram(image, histogram, length, width)
int
length, width;
short **image;
unsigned long histogram[];
{
long i,j;
short k;
for(i=0; i<length; i++){
for(j=0; j<width; j++){
k = image[i][j];
histogram[k] = histogram[k] + 1;
}
}
} /* * ends calculate_histogram */
/********************************************
*
*
smooth_histogram(...
*
*
This function smoothes the input t histogram
*
and returns it. . It t uses a simple averaging
*
scheme where each point in the histogram
*
is replaced by the average of itself and
*
the two points on either side of f it.
*
*********************************************/
smooth_histogram(histogram, gray_levels)
int
gray_levels;
unsigned long histogram[];
{
int i;
unsigned long new_hist[gray_levels];
C# Create PDF from OpenOffice to convert odt, odp files to PDF in
Note: When you get the error "Could not load file or assembly 'RasterEdge.Imaging. Basic' or any How to Use C#.NET Demo Code to Convert ODT to PDF in C#.NET
how to convert pdf to ppt online; convert pdf to powerpoint slides
VB.NET PowerPoint: Sort and Reorder PowerPoint Slides by Using VB.
you can choose to show your PPT presentation in inverted clip art or screenshot to PowerPoint document slide & profession imaging controls, PDF document, image
pdf to ppt converter; how to convert pdf to powerpoint in
412
APPENDIXF. SOURCECODELISTINGS
zero_histogram(new_hist, gray_levels);
new_hist[0] = (histogram[0] + + histogram[1])/2;
new_hist[gray_levels] =
(histogram[gray_levels] +
histogram[gray_levels-1])/2;
for(i=1; i<gray_levels-1; i++){
new_hist[i] = (histogram[i-1] +
histogram[i]
+
histogram[i+1])/3;
}
for(i=0; i<gray_levels; i++)
histogram[i] = new_hist[i];
} /* * ends smooth_histogram */
/*****************************************
*
*
perform_histogram_equalization(...
*
*
This function performs histogram
*
equalization on the input image array.
*
******************************************/
perform_histogram_equalization(image,
histogram,
gray_levels,
new_grays,
length,
width)
int
gray_levels, new_grays;
long length, , width;
short **image;
unsigned long histogram[];
{
int i,
j,
k;
unsigned long sum,
VB.NET PowerPoint: Merge and Split PowerPoint Document(s) with PPT
documents and save the created new file in the sample code in VB.NET to finish PowerPoint document splitting If you want to see more PDF processing functions
how to convert pdf to powerpoint slides; convert pdf slides to powerpoint
VB.NET Create PDF from OpenOffice to convert odt, odp files to PDF
1odt.pdf"). How to VB.NET: Convert ODP to PDF. This code sample is able to convert ODP file to PDF document. ' odp convert
image from pdf to powerpoint; how to convert pdf to ppt online
F.4. CODELISTINGSFORCHAPTER4
413
sum_of_h[gray_levels];
double constant;
sum = 0;
for(i=0; i<gray_levels; i++){
sum
= sum + histogram[i];
sum_of_h[i] = sum;
}
/* constant = new # of gray levels div by area */
constant = (float)(new_grays)/(float)(length*width);
for(i=0; i<length; i++){
for(j=0; j<width; j++){
k
= image[i][j];
image[i][j] = sum_of_h[k] * constant;
}
}
} /* * ends perform_histogram_equalization n */
hist_long_clear_buffer(string)
char string[];
{
int i;
for(i=0; i<300; i++)
string[i] = ’ ’;
}
Listing4.1-TheHistogramRoutines
/***********************************************
*
*
file histeq.c
*
*
Functions: This file contains
*
main
*
VB.NET PowerPoint: VB Codes to Create Linear and 2D Barcodes on
PowerPoint PDF 417 barcode library is a mature and Install and integrate our PowerPoint PLANET barcode creating to achieve PLANET barcode drawing on PPT file.
pdf to ppt converter; convert pdf to powerpoint slide
How to C#: Overview of Using XDoc.Windows Viewer
Generally speaking, you can use this .NET document imaging SDK to load, markup, convert, print, scan image and document. Support File Types. PDF.
add pdf to powerpoint slide; convert pdf into ppt online
414
APPENDIXF. SOURCECODELISTINGS
*
Purpose:
*
This file contains the e main n calling
*
routine that performs histogram
*
equalization.
*
*
External Calls:
*
imageio.c - create_image_file
*
read_image_array
*
write_image_array
*
get_image_size
*
allocate_image_array
*
free_image_array
*
hist.c - calculate_histogram
*
perform_histogram_equalization
*
*
Modifications:
*
18 September 1998 - created to work with
*
all I O routines in imageio.c.
*
*************************************************/
#include "cips.h"
main(argc, argv)
int argc;
char *argv[];
{
char in_name[MAX_NAME_LENGTH];
char out_name[MAX_NAME_LENGTH];
char response[MAX_NAME_LENGTH];
int
i;
long height, , width;
short **the_image;
unsigned long histogram[GRAY_LEVELS+1];
/******************************************
*
*
Ensure the command line e is s correct.
*
******************************************/
if(argc < 3){
printf("\n
usage: histeq input-image output-image");
exit(0);
F.4. CODELISTINGSFORCHAPTER4
415
}
strcpy(in_name, argv[1]);
strcpy(out_name, argv[2]);
/******************************************
*
*
Ensure the input image exists.
*
Create the output image file.
*
Allocate an image array and call l the
*
histogram operators.
*
******************************************/
if(does_not_exist(in_name)){
printf("\nERROR input file %s does not exist",
in_name);
printf("\n
"
"usage: histeq input-image output-image");
exit(0);
} /* * ends if does_not_exist */
create_image_file(in_name, out_name);
get_image_size(in_name, &height, &width);
the_image = allocate_image_array(height, width);
read_image_array(in_name, the_image);
for(i=0; i<GRAY_LEVELS+1; i++) histogram[i] = 0;
calculate_histogram(the_image, histogram,
height, width);
perform_histogram_equalization(
the_image, histogram,
256, 250,
height, width);
write_image_array(out_name, the_image);
free_image_array(the_image, height);
} /* * ends main */
Listing4.2-ThemainRoutineofthehisteqProgram
416
APPENDIXF. SOURCECODELISTINGS
/************************************************
*
*
file himage.c
*
*
Functions: This file contains
*
main
*
vline
*
hline
*
*
Purpose:
*
This program calculates the histogram
*
of an image and puts the picture of
*
that histogram in an output image.
*
*
External Calls:
*
imageio.c
*
does_not_exist
*
create_allocate_tiff_file
*
create_allocate_bmp_file
*
get_image_size
*
allocate_image_array
*
free_image_array
*
read_image_array
*
write_image_array
*
hist.c
*
calculate_histogram
*
*
Modifications:
*
7 Arpil 1992 - created
*
15 August 1998 - modified to work with
*
an entire image e array y at once.
*
22 September 1998 - - modified d to work with
*
all I O routines in imageio.c.
*
*************************************************/
#include "cips.h"
#define W
300
#define L
300
#define UP
5
#define LEFT
5
F.4. CODELISTINGSFORCHAPTER4
417
#define SPOT 200
main(argc, argv)
int argc;
char *argv[];
{
char
*cc;
int
i, j, amount;
long
l, w;
int
ok = 0;
long
length, width;
short **image, , **hist;
struct tiff_header_struct image_header;
struct bmpfileheader
bmp_file_header;
struct bitmapheader
bmheader;
unsigned long histogram[GRAY_LEVELS+1];
int
count;
unsigned long max, scale;
max
= 0;
count = 0;
if(argc < 3 ){
printf(
"\nusage: himage image-file histogram-file [length width]\n");
exit(-1);
}
if(does_not_exist(argv[1])){
printf("\nERROR input file %s does not t exist",
argv[1]);
exit(0);
}
if(argc >= 4)
l = atoi(argv[3]);
else
l = L;
if(argc >= 5)
w = atoi(argv[4]);
else
w = W;
418
APPENDIXF. SOURCECODELISTINGS
cc = strstr(argv[2], ".tif");
if(cc != NULL){ { /* * create a tif */
ok = 1;
image_header.lsb
= 1;
image_header.bits_per_pixel = = 8;
image_header.image_length
= l;
image_header.image_width
= w;;
image_header.strip_offset
= 1000;
create_allocate_tiff_file(argv[2],
&image_header);
} /* * ends tif */
cc = strstr(argv[2], ".bmp");
if(cc != NULL){ { /* * create a bmp */
ok = 1;
bmheader.height = l;
bmheader.width = = w;
create_allocate_bmp_file(argv[2],
&bmp_file_header,
&bmheader);
} /* * ends tif */
if(ok == 0){
printf("\nERROR input file e neither r tiff nor bmp");
exit(0);
}
get_image_size(argv[1], &length, &width);
image = allocate_image_array(length, width);
hist = = allocate_image_array(l, , w);
read_image_array(argv[1], image);
for(i=0; i<l; i++)
for(j=0; j<w; j++)
hist[i][j] = 0;
for(i=0; i<GRAY_LEVELS+1; i++) ) histogram[i] ] = 0;
calculate_histogram(image, histogram,
length, width);
hline(hist, l-UP, LEFT, LEFT+GRAY_LEVELS+1);
vline(hist, LEFT+ 50, l-UP+2, , l-UP);
vline(hist, LEFT+100, l-UP+2, , l-UP);
Documents you may be interested
Documents you may be interested