c# itextsharp convert pdf to image : Copy protecting pdf files Library SDK component .net wpf asp.net mvc cips2ed43-part124

F.4. CODE LISTINGS FOR CHAPTER 4
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 */
Listing 3.3- The dumpb Program
F.4 Code Listings for Chapter 4
/**************************************************
*
*
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 array.
*
They also modify an image by equalizing
*
its histogram.
*
*
Modifications:
Copy protecting pdf files - C# PDF Password Library: add, remove, edit PDF file password in C#.net, ASP.NET, MVC, WinForms, WPF
Help to Improve the Security of Your PDF Document by Setting Password
convert password protected pdf files to word online; break pdf password
Copy protecting pdf files - VB.NET PDF Password Library: add, remove, edit PDF file password in vb.net, ASP.NET, MVC, WinForms, WPF
Help to Improve the Security of Your PDF Document by Setting Password
advanced pdf password remover; a pdf password online
410
APPENDIX F. SOURCE CODE LISTINGS
*
July 86 - ported to IBM-PC
*
August 1990 - modified for use in the
*
C Image Processing System
*
March 1992 - removed the hardwired values
*
of 100 and replaced them with ROWS
*
and COLS. There are still some
*
hardwired numbers in 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 80
#define FORMFEED
’\014’
/*****************************************
*
*
zero_histogram(...
*
*
This function clears or 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 */
/*****************************************
C# PDF Library SDK to view, edit, convert, process PDF file for C#
Support protecting PDF file by adding password and digital file formats; merge, append, and split PDF files; insert, delete, move, rotate, copy and paste
password pdf files; password on pdf
.NET PDF SDK - Description of All PDF Processing Control Feastures
processing, extracting, annotating, compressing, and protecting PDF document can Able to remove and delete images from PDF; Easy to copy, paste, and cut image
pdf password unlock; convert pdf password protected to word online
F.4. CODE LISTINGS FOR CHAPTER 4
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 histogram
*
and returns it. It 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 it.
*
*********************************************/
smooth_histogram(histogram, gray_levels)
int
gray_levels;
unsigned long histogram[];
{
int i;
unsigned long new_hist[gray_levels];
C# PDF Image Redact Library: redact selected PDF images in C#.net
PDF file & pages edit, C#.NET PDF pages extract, copy, paste, C# Best .NET PDF document manipulation SDK library for PDF image information protecting in C#
pdf owner password; add password to pdf online
C# PDF Text Redact Library: select, redact text content from PDF
PDF file & pages edit, C#.NET PDF pages extract, copy, paste, C# Best .NET PDF document manipulation SDK control for PDF text content protecting in Visual
break a pdf password; convert password protected pdf to excel
412
APPENDIX F. SOURCE CODE LISTINGS
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,
C# HTML5 Viewer: Load, View, Convert, Annotate and Edit Raster
For instance, load images from stream or byte array, print images to tiff or pdf, annotate images Signature feature for protecting images. Images files can be
add password to pdf file; add password to pdf reader
F.4. CODE LISTINGS FOR CHAPTER 4
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 */
hist_long_clear_buffer(string)
char string[];
{
int i;
for(i=0; i<300; i++)
string[i] = ’ ’;
}
Listing 4.1 - The Histogram Routines
/***********************************************
*
*
file histeq.c
*
*
Functions: This file contains
*
main
*
414
APPENDIX F. SOURCE CODE LISTINGS
*
Purpose:
*
This file contains the main 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 is correct.
*
******************************************/
if(argc < 3){
printf("\n
usage: histeq input-image output-image");
exit(0);
F.4. CODE LISTINGS FOR CHAPTER 4
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 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 */
Listing 4.2 - The main Routine of the histeq Program
416
APPENDIX F. SOURCE CODE LISTINGS
/************************************************
*
*
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 array at once.
*
22 September 1998 - modified 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. CODE LISTINGS FOR CHAPTER 4
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 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
APPENDIX F. SOURCE CODE LISTINGS
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 neither 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