added wrapper edge-detect-display script, added sample image, red filter sample
git-svn-id: svn://anubis/gvsu@204 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
parent
5cd2b95b00
commit
e8baf24c7e
BIN
cs677/pa3/chryseobacterium.bmp
Normal file
BIN
cs677/pa3/chryseobacterium.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.8 MiB |
11
cs677/pa3/edge-detect-display
Executable file
11
cs677/pa3/edge-detect-display
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my @args = @ARGV;
|
||||
my $edgesFileName = $args[$#args];
|
||||
$edgesFileName =~ s/\.bmp$/-edges.bmp/i;
|
||||
|
||||
system('./edge-detect', @args);
|
||||
system('display', $edgesFileName);
|
@ -1,18 +1,62 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "BMP.h"
|
||||
using namespace std;
|
||||
|
||||
void usage(const char * progName)
|
||||
{
|
||||
cout << "Usage: " << progName << " [options] <input-BMP-file>" << endl;
|
||||
cout << " Options:" << endl;
|
||||
cout << " -l threshold_level : set threshold level" << endl;
|
||||
exit(42);
|
||||
}
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
BMP readfrom(argv[1]);
|
||||
unsigned char * data = new unsigned char[readfrom.getWidth() * readfrom.getHeight() * 3];
|
||||
readfrom.read(data);
|
||||
int argi;
|
||||
string inputFileName;
|
||||
string outputFileName;
|
||||
unsigned int threshold_level = 60;
|
||||
|
||||
BMP bmp_create((string(argv[1], strlen(argv[1]) - 4) + "-2.bmp").c_str(),
|
||||
readfrom.getWidth(),
|
||||
readfrom.getHeight(),
|
||||
if (argc < 2)
|
||||
usage(argv[0]);
|
||||
|
||||
for (argi = 0; argi < argc; argi++)
|
||||
{
|
||||
if (!strcmp(argv[argi], "-l"))
|
||||
{
|
||||
if (argi >= argc - 1)
|
||||
usage(argv[0]);
|
||||
argi++;
|
||||
threshold_level = atoi(argv[argi]);
|
||||
}
|
||||
else
|
||||
{
|
||||
inputFileName = argv[argi];
|
||||
outputFileName = string(argv[argi], strlen(argv[argi]) - 4);
|
||||
outputFileName += "-edges.bmp";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BMP inputImage(inputFileName.c_str());
|
||||
unsigned char * data =
|
||||
new unsigned char[inputImage.getWidth() * inputImage.getHeight() * 3];
|
||||
inputImage.read(data);
|
||||
|
||||
unsigned char * data_ptr = data;
|
||||
for (int i = 0; i < inputImage.getWidth() * inputImage.getHeight(); i++)
|
||||
{
|
||||
*data_ptr++ = 0;
|
||||
*data_ptr++ = 0;
|
||||
data_ptr++;
|
||||
}
|
||||
|
||||
BMP edges(outputFileName.c_str(),
|
||||
inputImage.getWidth(),
|
||||
inputImage.getHeight(),
|
||||
data);
|
||||
delete[] data;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user