diff options
author | crupest <crupest@outlook.com> | 2022-05-17 17:56:59 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-05-17 17:56:59 +0800 |
commit | 3f8f7f952e5b6094a0534931ce48f30ffd98f437 (patch) | |
tree | 1030b570909b9d19e375dd62ae2509886eaf9128 /works/life | |
parent | 2f0e9ebbbdaa4710846ee4606964c1bbf77698ed (diff) | |
download | crupest-3f8f7f952e5b6094a0534931ce48f30ffd98f437.tar.gz crupest-3f8f7f952e5b6094a0534931ce48f30ffd98f437.tar.bz2 crupest-3f8f7f952e5b6094a0534931ce48f30ffd98f437.zip |
import(life): ...
Diffstat (limited to 'works/life')
-rw-r--r-- | works/life/digital-image-process-lab/.gitignore | 2 | ||||
-rw-r--r-- | works/life/digital-image-process-lab/CMakeLists.txt | 11 | ||||
-rw-r--r-- | works/life/digital-image-process-lab/HistogramEqulization.cpp | 34 | ||||
-rw-r--r-- | works/life/test.ipynb | 49 |
4 files changed, 47 insertions, 49 deletions
diff --git a/works/life/digital-image-process-lab/.gitignore b/works/life/digital-image-process-lab/.gitignore new file mode 100644 index 0000000..d8c2a8f --- /dev/null +++ b/works/life/digital-image-process-lab/.gitignore @@ -0,0 +1,2 @@ +.clangd +build
\ No newline at end of file diff --git a/works/life/digital-image-process-lab/CMakeLists.txt b/works/life/digital-image-process-lab/CMakeLists.txt new file mode 100644 index 0000000..f87d227 --- /dev/null +++ b/works/life/digital-image-process-lab/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.20) + +project(digital-image-process-lab) + +set(CMAKE_CXX_STANDARD 17) + +find_package(OpenCV REQUIRED) +include_directories(${OpenCV_INCLUDE_DIRS}) +add_executable(HistogramEqulization HistogramEqulization.cpp) +target_link_libraries(HistogramEqulization ${OpenCV_LIBS}) + diff --git a/works/life/digital-image-process-lab/HistogramEqulization.cpp b/works/life/digital-image-process-lab/HistogramEqulization.cpp new file mode 100644 index 0000000..951a966 --- /dev/null +++ b/works/life/digital-image-process-lab/HistogramEqulization.cpp @@ -0,0 +1,34 @@ +#include <iostream> +#include <string> + +#include <opencv2/highgui.hpp> +#include <opencv2/imgcodecs.hpp> +#include <opencv2/imgproc.hpp> + +int main(int argc, char **argv) { + if (argc != 2) { + std::cerr << "Please input an image file path as the only arg." + << std::endl; + return -1; + } + + std::string file_name(argv[1]); + + cv::Mat src, dst; + + src = cv::imread(file_name, cv::IMREAD_COLOR); + if (src.empty()) { + std::cerr << "Failed to load image file: " << file_name << std::endl; + return -2; + } + + cv::cvtColor(src, src, cv::COLOR_BGR2GRAY); + + cv::equalizeHist(src, dst); + + cv::imshow("Source Image", src); + cv::imshow("Equalized Image", dst); + cv::waitKey(); + + return 0; +} diff --git a/works/life/test.ipynb b/works/life/test.ipynb deleted file mode 100644 index 7536d4b..0000000 --- a/works/life/test.ipynb +++ /dev/null @@ -1,49 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "tensor(6)\n" - ] - } - ], - "source": [ - "import torch\n", - "\n", - "t = torch.tensor([1, 2, 3]);\n", - "print(t.sum())\n" - ] - } - ], - "metadata": { - "interpreter": { - "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49" - }, - "kernelspec": { - "display_name": "Python 3.9.9 64-bit", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.9.9" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} |