From 4401f681d33f534a7d7ef8f4f940bd54b60710c3 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sun, 18 Sep 2022 01:52:26 -0400 Subject: Move stuff around to accommodate new family members. --- subslice_signature.cpp | 62 -------------------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 subslice_signature.cpp (limited to 'subslice_signature.cpp') diff --git a/subslice_signature.cpp b/subslice_signature.cpp deleted file mode 100644 index 75b1a43..0000000 --- a/subslice_signature.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//Chris Xiong 2022 -//License: MPL-2.0 -#include "subslice_signature.hpp" - -#include -#include -#include - -#include "imageutil.hpp" - -subsliced_signature subsliced_signature::from_path(const std::filesystem::path &path, - size_t nhslices, size_t nvslices, - const signature_config &fcfg, - const signature_config &scfg) -{ - cv::Mat img = image_util::imread_path(path, cv::IMREAD_UNCHANGED); - return subsliced_signature::from_cvmatrix(&img, nhslices, nvslices, fcfg, scfg); -} - -subsliced_signature subsliced_signature::from_file(const char *fn, - size_t nhslices, size_t nvslices, - const signature_config &fcfg, - const signature_config &scfg) -{ - cv::Mat img = cv::imread(fn, cv::IMREAD_UNCHANGED); - return subsliced_signature::from_cvmatrix(&img, nhslices, nvslices, fcfg, scfg); -} - -subsliced_signature subsliced_signature::from_cvmatrix(cv::Mat *m, - size_t nhslices, size_t nvslices, - const signature_config &fcfg, - const signature_config &scfg) -{ - subsliced_signature ret; - ret.full = signature::from_cvmatrix(m, fcfg); - cv::Mat *sm = m; - if (m->size().width / nhslices > 100 || m->size().height / nvslices > 100) - { - double sc = 100. * nhslices / m->size().width; - if (100. * nvslices / m->size().height < sc) - sc = 100. * nvslices / m->size().height; - sm = new cv::Mat(); - cv::resize(*m, *sm, cv::Size(), sc, sc, cv::InterpolationFlags::INTER_LINEAR); - } - ret.nhslices = nhslices; - ret.nvslices = nvslices; - int ssw = sm->size().width / nhslices; - int ssh = sm->size().height / nvslices; - for (int i = 0; i < nhslices; ++i) - for (int j = 0; j < nvslices; ++j) - { - int l = i * ssw; - int r = (i == nhslices) ? sm->size().width : (i + 1) * ssw; - int t = j * ssh; - int b = (j == nvslices) ? sm->size().height : (j + 1) * ssh; - cv::Mat slice = (*sm)(cv::Range(t, b), cv::Range(l, r)); - ret.subslices.push_back(std::move(signature::from_cvmatrix(&slice, scfg))); - } - if (sm != m) - delete sm; - return ret; -} -- cgit v1.2.3