From b3444b28d4a448bfe63c4560a4c4e2ae0cbd5d04 Mon Sep 17 00:00:00 2001 From: Omar Shrit Date: Wed, 25 Nov 2020 23:13:03 +0100 Subject: [PATCH] Remove strange characters situated at the end of each line I can not see what are these chars, but they are detect by kakoune and represented by a strange question mark. So I am removing them. Signed-off-by: Omar Shrit --- src/mlpack/core/data/load_image_impl.hpp | 190 +++++++++++------------ 1 file changed, 95 insertions(+), 95 deletions(-) diff --git a/src/mlpack/core/data/load_image_impl.hpp b/src/mlpack/core/data/load_image_impl.hpp index 8cd9b9a2ef..9a757838b9 100644 --- a/src/mlpack/core/data/load_image_impl.hpp +++ b/src/mlpack/core/data/load_image_impl.hpp @@ -1,96 +1,96 @@ -/** +/** * @file core/data/load_image_impl.hpp - * @author Mehul Kumar Nirala - * - * An image loading utility implementation. - * - * mlpack is free software; you may redistribute it and/or modify it under the - * terms of the 3-clause BSD license. You should have received a copy of the - * 3-clause BSD license along with mlpack. If not, see - * http://www.opensource.org/licenses/BSD-3-Clause for more information. - */ - -#ifndef MLPACK_CORE_DATA_LOAD_IMAGE_IMPL_HPP -#define MLPACK_CORE_DATA_LOAD_IMAGE_IMPL_HPP - -// In case it hasn't been included yet. -#include "load.hpp" - -namespace mlpack { -namespace data { - -// Image loading API. -template -bool Load(const std::string& filename, - arma::Mat& matrix, - ImageInfo& info, - const bool fatal) -{ - Timer::Start("loading_image"); - - // STB loads into unsigned char matrices, so we may have to convert once - // loaded. - arma::Mat tempMatrix; - const bool result = LoadImage(filename, tempMatrix, info, fatal); - - // If fatal is true, then the program will have already thrown an exception. - if (!result) - { - Timer::Stop("loading_image"); - return false; - } - - matrix = arma::conv_to>::from(tempMatrix); - Timer::Stop("loading_image"); - return true; -} - -// Image loading API for multiple files. -template -bool Load(const std::vector& files, - arma::Mat& matrix, - ImageInfo& info, - const bool fatal) -{ - if (files.size() == 0) - { - std::ostringstream oss; - oss << "Load(): vector of image files is empty." << std::endl; - - if (fatal) - Log::Fatal << oss.str(); - else - Log::Warn << oss.str(); - - return false; - } - - arma::Mat img; - bool status = LoadImage(files[0], img, info, fatal); - - if (!status) - return false; - - // Decide matrix dimension using the image height and width. - arma::Mat tmpMatrix( - info.Width() * info.Height() * info.Channels(), files.size()); - tmpMatrix.col(0) = img; - - for (size_t i = 1; i < files.size() ; ++i) - { - arma::Mat colImg(tmpMatrix.colptr(i), tmpMatrix.n_rows, 1, - false, true); - status = LoadImage(files[i], colImg, info, fatal); - - if (!status) - return false; - } - - matrix = arma::conv_to>::from(tmpMatrix); - return true; -} - -} // namespace data -} // namespace mlpack - -#endif + * @author Mehul Kumar Nirala + * + * An image loading utility implementation. + * + * mlpack is free software; you may redistribute it and/or modify it under the + * terms of the 3-clause BSD license. You should have received a copy of the + * 3-clause BSD license along with mlpack. If not, see + * http://www.opensource.org/licenses/BSD-3-Clause for more information. + */ + +#ifndef MLPACK_CORE_DATA_LOAD_IMAGE_IMPL_HPP +#define MLPACK_CORE_DATA_LOAD_IMAGE_IMPL_HPP + +// In case it hasn't been included yet. +#include "load.hpp" + +namespace mlpack { +namespace data { + +// Image loading API. +template +bool Load(const std::string& filename, + arma::Mat& matrix, + ImageInfo& info, + const bool fatal) +{ + Timer::Start("loading_image"); + + // STB loads into unsigned char matrices, so we may have to convert once + // loaded. + arma::Mat tempMatrix; + const bool result = LoadImage(filename, tempMatrix, info, fatal); + + // If fatal is true, then the program will have already thrown an exception. + if (!result) + { + Timer::Stop("loading_image"); + return false; + } + + matrix = arma::conv_to>::from(tempMatrix); + Timer::Stop("loading_image"); + return true; +} + +// Image loading API for multiple files. +template +bool Load(const std::vector& files, + arma::Mat& matrix, + ImageInfo& info, + const bool fatal) +{ + if (files.size() == 0) + { + std::ostringstream oss; + oss << "Load(): vector of image files is empty." << std::endl; + + if (fatal) + Log::Fatal << oss.str(); + else + Log::Warn << oss.str(); + + return false; + } + + arma::Mat img; + bool status = LoadImage(files[0], img, info, fatal); + + if (!status) + return false; + + // Decide matrix dimension using the image height and width. + arma::Mat tmpMatrix( + info.Width() * info.Height() * info.Channels(), files.size()); + tmpMatrix.col(0) = img; + + for (size_t i = 1; i < files.size() ; ++i) + { + arma::Mat colImg(tmpMatrix.colptr(i), tmpMatrix.n_rows, 1, + false, true); + status = LoadImage(files[i], colImg, info, fatal); + + if (!status) + return false; + } + + matrix = arma::conv_to>::from(tmpMatrix); + return true; +} + +} // namespace data +} // namespace mlpack + +#endif