removed folder structure
This commit is contained in:
parent
ffb486b0b9
commit
ab40eeb4e2
6 changed files with 430 additions and 6 deletions
53
smooth.cpp
Normal file
53
smooth.cpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
* Reads a PGM image and smooths it by some amount, then writes it back to disk
|
||||
*/
|
||||
#include <iostream>
|
||||
#include "bild.hpp"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if(argc < 2)
|
||||
{
|
||||
std::cout << "Usage: smooth <pgm file>" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
std::string filename = argv[1];
|
||||
|
||||
uint16_t smoothing;
|
||||
std::cout << "Wie oft soll das Bild geglaettet werden? ";
|
||||
std::cin >> smoothing;
|
||||
|
||||
// Load file
|
||||
std::ifstream file(filename);
|
||||
if(!file.good())
|
||||
{
|
||||
std::cerr << "Failed to open file" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Create image
|
||||
Bild image;
|
||||
try
|
||||
{
|
||||
file >> image;
|
||||
}
|
||||
catch(const std::runtime_error& err)
|
||||
{
|
||||
std::cerr << err.what() << std::endl;
|
||||
file.close();
|
||||
return -1;
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
||||
// Print image
|
||||
for(uint8_t i = 0; i < smoothing; i++)
|
||||
image = image.Geglaettet();
|
||||
|
||||
filename.insert(filename.find('.'), "_modified");
|
||||
std::ofstream outFile(filename);
|
||||
outFile << image;
|
||||
outFile.close();
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue