Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "PDIUtils.h"
- #include <algorithm>
- #include <cmath>
- cv::Mat PDIUtils::escalaCinza(cv::Mat imagemColorida) {
- cv::Mat aux = imagemColorida.clone();
- cv::cvtColor(imagemColorida, aux, cv::COLOR_BGR2GRAY);
- return aux;
- }
- cv::Mat PDIUtils::negativo(cv::Mat imagemBase) {
- cv::Mat aux = imagemBase.clone();
- for (int x = 0; x < aux.rows; x++) {
- for (int y = 0; y < aux.cols; y++) {
- PixelEC pixel = imagemBase.at<PixelEC>(x, y);
- PixelEC negativo = 255 - pixel;
- aux.at<PixelEC>(x, y) = negativo;
- }
- }
- return aux;
- }
- cv::Mat PDIUtils::canal(cv::Mat imagemColorida, int canal) {
- cv::Mat aux = escalaCinza(imagemColorida);
- for (int x = 0; x < aux.rows; x++) {
- for (int y = 0; y < aux.cols; y++) {
- Pixel pixel = imagemColorida.at<Pixel>(x, y);
- PixelEC pCanal = pixel[canal];
- aux.at<PixelEC>(x, y) = pCanal;
- }
- }
- return aux;
- }
- std::vector<float> PDIUtils::histograma(cv::Mat imagem) {
- std::vector<float> hist = std::vector<float>(256);
- for (int i = 0; i < imagem.rows; i++) {
- for (int j = 0; j < imagem.cols; j++) {
- PixelEC pixel = imagem.at<PixelEC>(i, j);
- hist[pixel]++;
- }
- }
- //faz o histograma
- return hist;
- }
- cv::Mat PDIUtils::limiarizacao(cv::Mat imagemBase, int limiar) {
- cv::Mat aux = imagemBase.clone();
- //limiariza a imagem
- return aux;
- }
- cv::Mat PDIUtils::janelamento(cv::Mat imagemBase, int li, int ls) {
- cv::Mat aux = imagemBase.clone();
- //faz o janelamento da imagem
- return aux;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement