DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T s

⟦c5d3a7310⟧ TextFile

    Length: 1700 (0x6a4)
    Types: TextFile
    Names: »scale.c++«

Derivation

└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
    └─ ⟦this⟧ »EUUGD11/euug-87hel/sec1/image/vartools/scale.c++« 

TextFile


/*
    This file contains the declarations necessary to scale 
    the pixels in images.
*/

#include <stream.h>
#include <stdio.h>
#include <string.h>
#include <double_image.h++>
#include "vartools.h++"

/*
    This takes an image as input and create another
*/
double_image&
scale2(double scale, double increment, double_image& input, FILE *output_file)
    {
    // create the output image 
    double_image *output_pointer = 
	new double_image(CREATE,input.n_rows(),input.n_cols(),output_file);
    double_image& output = *output_pointer;

    // scale  and increment the image
    while(input++,output++)
	{
	output() = input() * scale + increment;
	}
    
    return output;
    }

/*
    This takes two files and takes one and puts a scaled version into the other
*/
void
scale(double scale, double increment, FILE *input, FILE *output, char * comment)
    {
    // read in the input image
    double_image input_image(READ,input);
    // scale and  increment it
    double_image& output_image = scale2(scale,increment,input_image,output);
    // set up the comments
    output_image.set_comments(comment,strlen(comment));
    // add the comments 
    char *string = 
	form("Scaling image: scale %lf increment %lf\n",scale,increment);
    output_image.add_comment(string,strlen(string));
    output_image.add_comment((char *) input_image.the_comments(),input_image.c_length());

    // output the image to file
    output_image.write();
    }
/*
Copyright (C) 1986, David Sher in the University of Rochester
Permission is granted to any individual or institution to use, copy, or
redistribute this software so long as it is not sold for profit, provided
this copyright notice is retained.
*/