Ask Your Question

rajib86's profile - activity

2020-05-04 06:05:30 -0600 received badge  Popular Question (source)
2019-04-02 22:53:48 -0600 received badge  Popular Question (source)
2016-06-13 10:25:11 -0600 received badge  Student (source)
2014-06-08 10:06:28 -0600 commented answer How Do I Show value of the Angle After Completing Fourier Transform In Opencv?

Thanks for your replay.I have flow your instruction.But i need to calculate the angle,How many degree, example 45 degree, in my screen it will show 45 degree. Mat magnitude,angl; cartToPolar(planes[0],planes[1], magnitude,angl,true); cout << "degree=" <<true << endl; log(magnitude,magnitude); magnitude = magnitude(Rect(0, 0, magnitude.cols & -2, magnitude.rows & -2));

2014-06-08 09:53:02 -0600 received badge  Scholar (source)
2014-06-05 07:40:07 -0600 asked a question How Do I Show value of the Angle After Completing Fourier Transform In Opencv?

I am new in opencv. After completing Fourier transform, i have also got display the angle.I want to show in my window how many degree it is.please give me some idea.

// crop the spectrum, if it has an odd number of rows or columns
    canny_image = canny_image(Rect(0, 0, canny_image.cols & -2, canny_image.rows & -2));


 // rearrange the quadrants of Fourier image  so that the origin is at the image center
    int cx = canny_image.cols/2;
    int cy = canny_image.rows/2;

    Mat q0(canny_image, Rect(0, 0, cx, cy));   // Top-Left - Create a ROI per quadrant
    Mat q1(canny_image, Rect(cx, 0, cx, cy));  // Top-Right
    Mat q2(canny_image, Rect(0, cy, cx, cy));  // Bottom-Left
    Mat q3(canny_image, Rect(cx, cy, cx, cy)); // Bottom-Right

    Mat tmp;                           // swap quadrants (Top-Left with Bottom-Right)
    q0.copyTo(tmp);
    q3.copyTo(q0);
    tmp.copyTo(q3);

    q1.copyTo(tmp);                    // swap quadrant (Top-Right with Bottom-Left)
    q2.copyTo(q1);
    tmp.copyTo(q2);

    normalize(canny_image, canny_image, 0, 1, CV_MINMAX); // Transform the matrix with float values into a
                                            // viewable image form (float between values 0 and 1).
 imshow("spectrum magnitude", canny_image);
2014-05-15 18:58:29 -0600 commented question How Do I Calculates The Angle Of Orientation Of The Image With The Fourier Transform?

Hello, I have an image I applied the fourier transform for the orientation angle,but i face here channels problem.When i build this program,it shows success but it's not run.It is showing "Open cv Error: Assertion failed <_tp>::channels==m.channels<>>in unknown function, file c:\opencv\opencv\build\include\opencv2/core/mat.hpp,line890" i used Breakpoint in this code when it comes this line "Mat planes[] = {Mat_(padded), Mat::zeros(padded.size(), CV_32F)};"then it break.Personally I do not know how i solve this problem because I have no error! Please help me

2014-05-15 18:57:31 -0600 received badge  Editor (source)
2014-05-15 18:41:58 -0600 asked a question How Do I Calculates The Angle Of Orientation Of The Image With The Fourier Transform?
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <stdlib.h>
#include <stdio.h>
#include <opencv2\opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <stdint.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>

using namespace cv;
using namespace std;
/// Global variables
Mat src, src_gray,canny_image,padded,good_f_t, threshold_image,lowerRect,imageROI,dst, detected_edges;
int edgeThresh = 1;
int lowThreshold;
int const max_lowThreshold = 100;
int ratio = 3;
int kernel_size = 3;
char* window_name = "Edge Map";
void CannyThreshold(int, void*)
{
  blur( src_gray, detected_edges, Size(3,3) );
    Canny( detected_edges, detected_edges, lowThreshold, lowThreshold*ratio, kernel_size );
    dst = Scalar::all(0);
    src.copyTo( dst, detected_edges);
    imshow( window_name, dst );
   Mat padded;                           
    int m = getOptimalDFTSize( dst.rows );
    int n = getOptimalDFTSize( dst.cols ); 
    copyMakeBorder(dst, padded, 0, m - dst.rows, 0, n - dst.cols, BORDER_CONSTANT, Scalar::all(0));
    Mat planes[] = {Mat_<float>(padded), Mat::zeros(padded.size(), CV_32F)};      
    Mat complexdst;
    merge(planes, 2, complexdst);        
    dft(complexdst, complexdst);            

    split(complexdst, planes);                   
    magnitude(planes[0], planes[1], planes[0]);
    Mat magdst = planes[0];
    magdst += Scalar::all(1);                    
    log(magdst, magdst);
    magdst = magdst(Rect(0, 0, magdst.cols & -2, magdst.rows & -2));
    int cx = magdst.cols/2;
    int cy = magdst.rows/2;
    Mat q0(magdst, Rect(0, 0, cx, cy));   
    Mat q1(magdst, Rect(cx, 0, cx, cy));  
    Mat q2(magdst, Rect(0, cy, cx, cy));  
    Mat q3(magdst, Rect(cx, cy, cx, cy));
     Mat tmp;                           
    q0.copyTo(tmp);
    q3.copyTo(q0);
    tmp.copyTo(q3);

    q1.copyTo(tmp);                    
    q2.copyTo(q1);
    tmp.copyTo(q2);

    normalize(magdst, magdst, 0, 1, CV_MINMAX); 
    imshow("spectrum magnitude", magdst);
    }


int main( int argc, char** argv )
{
    src = imread("C:/Users/Saha/Desktop/DSCF0563.JPG");
    resize(src, src, Size(), 0.2, 0.2, INTER_LANCZOS4);

  if( !src.data )
  { return -1; }

 dst.create( src.size(), src.type() );

 cvtColor( src, src_gray, CV_BGR2GRAY );

 namedWindow( window_name, CV_WINDOW_AUTOSIZE );

   createTrackbar( "Min Threshold:", window_name, &lowThreshold, max_lowThreshold, CannyThreshold );

    CannyThreshold(0, 0);

    waitKey(0);

  return 0;
  }
2014-05-15 08:34:07 -0600 asked a question Calculates the angle of orientation of the image with the fourier transform

Hello, I have an image I applied the fourier transform for the orientation angle,but i face here channels problem.When i build this program,it shows success but it's not run.It is showing "Open cv Error: Assertion failed <datatype<_tp>::channels==m.channels<>>in unknown function, file c:\opencv\opencv\build\include\opencv2/core/mat.hpp,line890" i used Breakpoint in this code when it comes this line "Mat planes[] = {Mat_<float>(padded), Mat::zeros(padded.size(), CV_32F)};"then it break.Personally I do not know how i solve this problem because I have no error! Please help me

include "opencv2/imgproc/imgproc.hpp"

include "opencv2/highgui/highgui.hpp"

include <stdlib.h>

include <stdio.h>

include <opencv2\opencv.hpp>

include <opencv2 highgui="" highgui.hpp="">

include <opencv2 core="" core.hpp="">

include <stdint.h>

include <opencv2 imgproc="" imgproc.hpp="">

include <iostream>

using namespace cv; using namespace std; Mat src, src_gray,canny_image,padded,good_f_t, threshold_image,lowerRect,imageROI,dst, detected_edges;

int edgeThresh = 1; int lowThreshold; int const max_lowThreshold = 100; int ratio = 3; int kernel_size = 3; char* window_name = "Edge Map";

/* * @function CannyThreshold * @brief Trackbar callback - Canny thresholds input with a ratio 1:3 */ void CannyThreshold(int, void) { /// Reduce noise with a kernel 3x3 blur( src_gray, detected_edges, Size(3,3) );

/// Canny detector Canny( detected_edges, detected_edges, lowThreshold, lowThreshold*ratio, kernel_size );

/// Using Canny's output as a mask, we display our result dst = Scalar::all(0);

src.copyTo( dst, detected_edges); imshow( window_name, dst ); /-----------------------fourier transform--------------------------/ Mat padded; //expand input image to optimal size int m = getOptimalDFTSize( dst.rows ); int n = getOptimalDFTSize( dst.cols ); // on the border add zero values copyMakeBorder(dst, padded, 0, m - dst.rows, 0, n - dst.cols, BORDER_CONSTANT, Scalar::all(0));

Mat planes[] = {Mat_<float>(padded), Mat::zeros(padded.size(), CV_32F)};      
Mat complexdst;
merge(planes, 2, complexdst);         // Add to the expanded another plane with zeros

dft(complexdst, complexdst);            // this way the result may fit in the source matrix

// compute the magnitude and switch to logarithmic scale
// => log(1 + sqrt(Re(DFT(I))^2 + Im(DFT(I))^2))
split(complexdst, planes);                   // planes[0] = Re(DFT(I), planes[1] = Im(DFT(I))
magnitude(planes[0], planes[1], planes[0]);// planes[0] = magnitude
Mat magdst = planes[0];

magdst += Scalar::all(1);                    // switch to logarithmic scale
log(magdst, magdst);

// crop the spectrum, if it has an odd number of rows or columns
magdst = magdst(Rect(0, 0, magdst.cols & -2, magdst.rows & -2));

// rearrange the quadrants of Fourier image  so that the origin is at the image center
int cx = magdst.cols/2;
int cy = magdst.rows/2;

Mat q0(magdst, Rect(0, 0, cx, cy));   // Top-Left - Create a ROI per quadrant
Mat q1(magdst, Rect(cx, 0, cx, cy));  // Top-Right
Mat q2(magdst, Rect(0, cy, cx, cy));  // Bottom-Left
Mat q3(magdst, Rect(cx, cy, cx, cy)); // Bottom-Right

Mat tmp;                           // swap quadrants (Top-Left with Bottom-Right)
q0.copyTo(tmp);
q3.copyTo(q0);
tmp.copyTo(q3);

q1.copyTo(tmp);                    // swap quadrant (Top-Right with Bottom-Left)
q2.copyTo(q1);
tmp.copyTo(q2);

normalize(magdst, magdst, 0, 1, CV_MINMAX); // Transform ...
(more)
2014-03-03 02:33:27 -0600 asked a question how i set canny image to region of interest using open cv?

After performing canny , how do i access bright pixel? Also how can take those out using region of interest?

2014-03-03 02:28:05 -0600 asked a question how to set region of interest(ROI)?

After performing canny , how do i access bright pixel? Also how can take those out using region of interest?