Accessing the Value for each Pixel of an Output Array of phase() [closed]
I want to make an Matrix which holds the Orientation value of each pixel in a image. I need it for methods I want to use on the source image later on. The Code I have for this at the moment looks like this:
#include <iostream>
#include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;
Mat src; Mat dst; Mat tmp;
void orientationMap(const cv::Mat& ori, double thresh = 1.0){
int i, j;
int** hist = 0;
hist = new int*[15];
for( i = 0; i < ori.rows; i++){
hist[i] = new int[15];
for( j = 0; j < ori.cols; j++){
int pixelValue = (int)ori.at<uchar>(i,j);
cout << pixelValue << endl;
}
}
}
int main(int argc, const char * argv[]) {
String imgName("example.jpg");
src = imread(imgName,0);
Mat patch = src(Rect(30,30,15,15));
Mat Sx;
Sobel(patch, Sx, CV_32F, 1,0,3);
Mat Sy;
Sobel(patch, Sy, CV_32F, 0, 1, 3);
Mat mag, ori;
magnitude(Sx, Sy, mag);
phase(Sx, Sy, ori, true);
orientationMap(ori, 1.0);
return 0;
}
What I want to do know, is to access the Image (ori) and read out the Orientation Values and divid them by 10 to get a number between 0 and 36. And add that one in an array. The Method I use now just gives me the gray value of the Image.
Here is the Solution for others with the same problem:
int i,j;
int** hist = 0;
hist = new int*[15];
for(i = 0; i < ori.rows; i++){
hist[i] = new int[15];
for(j = 0; j < ori.cols; j++){
float value = round(ori.at<float>(i,j) / 10);
hist[i][j] = value;
}
}