Procurar
Últimos assuntos
Quem está conectado?
Há 2 usuários online :: 0 registrados, 0 invisíveis e 2 visitantes Nenhum
[ Ver toda a lista ]
O recorde de usuários online foi de 192 em Ter Out 26, 2021 6:07 am
Operações com matrizes openCv
Página 1 de 1
Operações com matrizes openCv
- Código:
#include <iostream>
#include "opencv2/opencv.hpp"
using namespace cv;
using namespace std;
void printMatriz(Mat img){
//imprimindo matriz
cout <<"matriz"<<endl;
for(int i =0; i< img.rows; i++){
cout<<endl;
for(int j=0; j<img.cols;j++){
cout<<int(img.at<uchar>(i,j));
}
}
}
void printValor(string titulo, Mat x){
cout << titulo <<endl;
cout << x <<endl;
}
void printInfo(Mat x){
///info
cout << "img=" << x <<endl <<endl;
cout << "Tamanho=" << x.size() << endl<<endl;
cout << "Profunidade=" << x.depth() << endl<<endl;
cout << "Canais=" << x.channels() << endl<<endl;
cout << "Tipo=" << x.type() << endl<<endl;
cout << "Total=" << x.total() << endl<<endl;
}
void reendMatriz(Mat A){
Mat B(A);
printValor("Matriz A",A);
printValor("Matriz B",B);
B.at<Vec3b>(1,0)=Vec3b(3,2,1);
printValor("Matriz A MODIFICADA",A);
printValor("Matriz B MODIFICADA",B);
}
void roiMATRIZ(Mat img){
}
void layerMatriz(Mat A){
vector<Mat>B(3);
split(A,B); //exploder a matriz em 3 canais
cout << A <<endl<<endl;
cout << B[0] << endl<<endl;
cout << B[1] <<endl <<endl;
cout << B[2] << endl << endl;
}
//reendereçar uma matriz
void layerMerge(Mat A){
vector<Mat>B(3);
split(A,B);
B[1]=B[1]-2;
merge(B,A);
cout <<A << endl << endl;
}
void lixo(){
///fuc
//pegando posic
//int valor = img.at<uchar>(1,1); //matriz 1 canal
//Vec3b valor = img.at<Vec3b>(1,0); //matriz 1 canal
//cout << valor <<endl;
/////alterando valor
http://img.at<Vec3b>(1,0)=Vec3b(3,2,1);
//cout<<img.at<Vec3b>(1,0)<<endl;
}
void converteMatriz(Mat A){
Mat B;
printValor("Matriz A", A);
printValor("Matriz B", B);
A.convertTo(B,CV_32F);
printValor("Matriz A", A/2);
printValor("Matriz B", B/2);
}
int main(int argc, char** argv )
{
cout << "\t\t\t\t\tTeste"<< endl;
///matriz
// Mat img= (Mat_<int>(3,3)<<1,1,1,2,2,2,3,3,3);
Mat img= Mat(3,3,CV_8UC1,Scalar(3));//povoa a matriz
// Mat img=Mat::ones(3,3,CV_8UC1);//povoa com 1
//Mat img=Mat::eye(3,3,CV_8UC1);//matriz inversa
// Mat img=Mat::eye(3,3,CV_8UC3);//matriz inversa 3 canais
// Mat img=Mat::zeros(3,3,CV_8UC1);//matriz inversa
converteMatriz(img);
//layerMatriz(img);
//layerMerge(img);
//reendMatriz(img);
return 0;
}
void layerMatriz(Mat A){
vector<Mat>B(3);
split(A,B); //exploder a matriz em 3 canais
cout << A <<endl<<endl;
cout << B[0] << endl<<endl;
cout << B[1] <<endl <<endl;
cout << B[2] << endl << endl;
}
//reendereçar uma matriz
void layerMerge(Mat A){
vector<Mat>B(3);
split(A,B);
B[1]=B[1]-2;
merge(B,A);
cout <<A << endl << endl;
}
void lixo(){
///fuc
//pegando posic
//int valor = img.at<uchar>(1,1); //matriz 1 canal
//Vec3b valor = img.at<Vec3b>(1,0); //matriz 1 canal
//cout << valor <<endl;
/////alterando valor
http://img.at<Vec3b>(1,0)=Vec3b(3,2,1);
//cout<<img.at<Vec3b>(1,0)<<endl;
}
void converteMatriz(Mat A){
Mat B;
printValor("Matriz A", A);
printValor("Matriz B", B);
A.convertTo(B,CV_32F);
printValor("Matriz A", A/2);
printValor("Matriz B", B/2);
}
int main(int argc, char** argv )
{
cout << "\t\t\t\t\tTeste"<< endl;
///matriz
// Mat img= (Mat_<int>(3,3)<<1,1,1,2,2,2,3,3,3);
Mat img= Mat(3,3,CV_8UC1,Scalar(3));//povoa a matriz
// Mat img=Mat::ones(3,3,CV_8UC1);//povoa com 1
//Mat img=Mat::eye(3,3,CV_8UC1);//matriz inversa
// Mat img=Mat::eye(3,3,CV_8UC3);//matriz inversa 3 canais
// Mat img=Mat::zeros(3,3,CV_8UC1);//matriz inversa
converteMatriz(img);
//layerMatriz(img);
//layerMerge(img);
//reendMatriz(img);
return 0;
}
juk- Mensagens : 266
Data de inscrição : 02/04/2012
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos
Ontem à(s) 9:27 pm por juk
» LINKS PARA BAIXAR O OFFICE
Ter Abr 23, 2024 5:57 pm por juk
» Backup FULL FIREFOX
Dom Abr 07, 2024 3:16 pm por juk
» Backup FULL CHROME
Dom Abr 07, 2024 2:59 pm por juk
» Dowloand de Videos youtube Sem Permissão adminstrador
Seg Jan 02, 2023 2:13 pm por juk
» Cypecad 2019
Seg Jan 02, 2023 1:41 pm por juk
» Atualizando é instalando o IExplorer 11 no windows 7
Ter Ago 30, 2022 10:54 pm por juk
» COMO HABILITAR INTERNET EXPLORER NO WINDOWS 10
Sex Abr 29, 2022 6:43 pm por juk
» Usando o Monitor de Recursos do sistema para identificar processos Associados.
Qua Abr 06, 2022 10:19 am por juk