72
edits
Changes
→Testing and Demonstration Program
=='''Testing and Demonstration Program'''==
We broke down are program into a tester class and have main in our Demo.cpp. This was done in order for the code to be more human readable in demonstration purposes.
<syntaxhighlight>
class Tester {
Timer timer;
cv::Mat img_;
std::string outputPath_;
std::string outputPostfix_;
std::string imgPath_;
openMP_imgProcessor omp_processor_ = openMP_imgProcessor();
serial_imgProcessor serial_processor_ = serial_imgProcessor();
IppImgProc ipp_processor_;
std::vector<long long> results_;
public:
Tester(std::string imgPath) {
imgPath_ = imgPath;
ipp_processor_ = IppImgProc(imgPath_);
img_ = cv::imread(imgPath);
if (img_.empty()) std::cerr << "empty img!\n" << "unable to locate img at " << imgPath << std::endl;
outputPath_ = imgPath.substr(0, imgPath.find_last_of("."));
outputPath_ += "_modified";
outputPostfix_ = imgPath.substr(imgPath.find_last_of("."), imgPath.length());
}
void omp_brighten(int level) {
cv::Mat outputImg = img_.clone();
timer.reset();
timer.start();
omp_processor_.brightenImg(outputImg, level);
timer.stop();
std::cout << "Image brightening time w/ OpenMP: " << timer.currtime() << " milliseconds" << std::endl;
results_.push_back(timer.currtime());
cv::imwrite(outputPath_ + "_brightened_omp" + outputPostfix_, outputImg);
}
void omp_sharpen() {
cv::Mat outputImg = img_.clone();
timer.reset();
timer.start();
omp_processor_.sharpenImg(outputImg);
timer.stop();
std::cout << "Image sharpening time w/ OpenMP: " << timer.currtime() << " milliseconds" << std::endl;
results_.push_back(timer.currtime());
cv::imwrite(outputPath_ + "_sharpened_omp" + outputPostfix_, outputImg);
}
void omp_saturate(int level) {
cv::Mat outputImg = img_.clone();
timer.reset();
timer.start();
omp_processor_.saturateImg(outputImg, level);
timer.stop();
std::cout << "Image increased saturation time w/ OpenMP: " << timer.currtime() << " milliseconds" << std::endl;
results_.push_back(timer.currtime());
cv::imwrite(outputPath_ + "_saturated_omp" + outputPostfix_, outputImg);
}
void ipp_brighten(int level) {
cv::Mat outputImg = cv::Mat::zeros(img_.size(), img_.type());
timer.reset();
timer.start();
ipp_processor_.brighten(level, 0);
timer.stop();
results_.push_back(timer.currtime());
std::cout << "Image brighten time w/ IPP: " << timer.currtime() << " milliseconds\n";
//cv::imwrite(outputPath_ + "_bright_ipp" + outputPostfix_, outputImg);
ipp_processor_.saveOutputImage(outputPath_ + "_bright_ipp" + outputPostfix_);
}
void ipp_sharpen() {
//cv::Mat outputImg = img_.clone();
timer.reset();
timer.start();
ipp_processor_.sharpening();
timer.stop();
std::cout << "Image sharpen time w/ IPP: " << timer.currtime() << " milliseconds\n";
ipp_processor_.saveOutputImage(outputPath_ + "_sharp_ipp" + outputPostfix_);
}
void ipp_saturate() {
cv::Mat outputImg = img_.clone();
timer.reset();
timer.start();
ipp_processor_.adjustSaturation(150);
timer.stop();
std::cout << "Image saturation time w/ IPP: " << timer.currtime() << " milliseconds\n";
ipp_processor_.saveOutputImage(outputPath_ + "_saturate_ipp" + outputPostfix_);
}
void serial_brighten(int level) {
cv::Mat outputImg = img_.clone();
timer.reset();
timer.start();
serial_processor_.brightenImg(outputImg, level);
timer.stop();
std::cout << "Image brightening time: " << timer.currtime() << " milliseconds" << std::endl;
results_.push_back(timer.currtime());
cv::imwrite(outputPath_ + "_brightened_serial" + outputPostfix_, outputImg);
}
void serial_sharpen() {
cv::Mat outputImg = img_.clone();
timer.reset();
timer.start();
serial_processor_.sharpenImg(outputImg);
timer.stop();
std::cout << "Image sharpening time: " << timer.currtime() << " milliseconds" << std::endl;
results_.push_back(timer.currtime());
cv::imwrite(outputPath_ + "_sharpened_serial" + outputPostfix_, outputImg);
}
void serial_saturate(int level) {
cv::Mat outputImg = img_.clone();
timer.reset();
timer.start();
serial_processor_.saturateImg(outputImg, level);
timer.stop();
std::cout << "Image saturating time: " << timer.currtime() << " milliseconds" << std::endl;
results_.push_back(timer.currtime());
cv::imwrite(outputPath_ + "_saturated_serial" + outputPostfix_, outputImg);
}
};
</syntaxhighlight>
=='''Results'''==