opencv - How to capture hair wisp structure from an image? -


i want draw cue specified point along gradient direction capture structure of hair wisp. figure2. , figure3. acm paper, linked here: single-view hair modeling portrait manipulation. draw orientation map gradients, results chaotic. code:

#include <opencv2\highgui\highgui.hpp> #include <opencv2\imgproc\imgproc.hpp> #include <iostream>  using namespace cv; using namespace std;  int main(int argv, char* argc[]) {     mat image = imread("wavy.jpg", 0);     if(!image.data)         return -1;      mat sobelx1;     sobel(image, sobelx1, cv_8u, 1, 0, 3);     //imshow("x direction", sobelx);      mat sobely1;     sobel(image, sobely1, cv_8u, 1, 0, 3);     //imshow("y direction", sobely);      mat sobelx, sobely;     sobelx1.convertto(sobelx, cv_32f, 1./255);     sobely1.convertto(sobely, cv_32f, 1./255);      double l_max = -10;     (int y = 0; y < image.rows; y+=3)                                                           // first iteration, compute maximum l (longest flow)     {         (int x = 0; x < image.cols; x+=3)         {             double dx = sobelx.at<float>(y, x);                                                        // gets x component of flow             double dy = sobely.at<float>(y, x);                                                        // gets y component of flow              cvpoint p = cvpoint(y, x);              double l = sqrt(dx*dx + dy*dy);                                                             // function sets basic threshold drawing on image              if(l>l_max) l_max = l;         }     }      (int y = 0; y < image.rows; y+=3)     {         (int x = 0; x < image.cols; x+=3)     {         double dx = sobelx.at<float>(y, x);                                                        // gets x component of flow         double dy = sobely.at<float>(y, x);                                                        // gets y component of flow          cvpoint p = cvpoint(x, y);          double l = sqrt(dx*dx + dy*dy);                                                             // function sets basic threshold drawing on image         if (l > 0)         {             double spinsize = 5.0 * l/l_max;                                                        // factor normalise size of spin depending on length of arrow              cvpoint p2 = cvpoint(p.x + (int)(dx), p.y + (int)(dy));             line(image, p, p2, cv_rgb(0,255,0), 1, cv_aa);              double angle;                                                                           // draws spin of arrow             angle = atan2( (double) p.y - p2.y, (double) p.x - p2.x);              p.x = (int) (p2.x + spinsize * cos(angle + 3.1416 / 4));             p.y = (int) (p2.y + spinsize * sin(angle + 3.1416 / 4));             line(image, p, p2, cv_rgb(0,255,0), 1, cv_aa, 0 );         }     }     }      imshow("orientation map", image);     waitkey(0);     return 0; } 

can 1 give me hints?

your sobels same while supposed have different code x , y. 0, 1 , 1, 0.on top of loose resolution , sign specifying cv8u depth insobel , converting float. please provide input resolution , outcome image.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -