main.cc.html
//**************************************************************************
//
// CSE 486 Project #2
// By Anirudh Modi (anirudh@bart.aero.psu.edu) on 3/8/99-Mon
// & Jim Geis (geis@cse.psu.edu)
// & Howard Elikan (elikan@cse.psu.edu)
//
//**************************************************************************
// Running time of algorithm -> O[width x height]
//**************************************************************************
// Have implemented the following ->
// 1. Smoothening of histogram to determine minima/maxima
// 2. Basic image operations (+, -, =)
// 3. Morphological Operators [NEW]
// 4. Image Filters [NEW]
//**************************************************************************
#include <iostream.h>
#include <fstream.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "image.h"
//**************************************************************************
int main (int argc, char *argv[])
{
if (argc != 2)
{
cerr << "Syntax: " << argv[0] << " <pbm-image-file>" << endl;
exit(-1);
}
GrayImage image;
char name[50];
image.ReadFromFile(argv[1]); // Read the image file
//image.MeanFilterNxN ( 5 ); // For cupnoise.pgm
//image.ClosingNxN ( 7 ); // For cupnoise.pgm
//image.Threshold(90); // For cupnoise.pgm
int GrayScale = 1; // 1 for GrayScale and 0 for Binary
if (!GrayScale)
{
image.ConvertToBinary( );
image.LabelComponents( );
}
//image.ClosingNxN ( 3 ); // For match1.dat
image.Skeletonization ( ); // For match1.dat
sprintf(name,"%s.out",argv[1]);
if (!GrayScale)
image.WriteLabelsToFile(name);
else
image.WriteToFile(name);
}
//**************************************************************************