OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Sat, 14 Jul 2018 22:41:09 -05002D spline algorithm in OpenCVhttp://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/Does OpenCV have a method for generating a 2D 'spline' contour? IOW, choose gray-scale pixel values at selected points on a 2D map and have them connected by a smoothed 2-dimensional contour. Output would presumably be gray-scale values in Mat form.
The inputs to a regular spline are a set of point coordinates, and output is a continuous curve that connects the input points.
In this case, the input would be a set of point coordinates -each with a gray-scale value-. The output would be a smoothed gray-scale contour that covers the entire square Mat.
That was tougher to explain than I expected. Hope it was clear. Perhaps that would actually be a 3D spline in that gray-scale value would be the 3rd dimension. But this is for generating a 2D image.
Mon, 04 Jun 2018 05:29:03 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/Comment by berak for <p>Does OpenCV have a method for generating a 2D 'spline' contour? IOW, choose gray-scale pixel values at selected points on a 2D map and have them connected by a smoothed 2-dimensional contour. Output would presumably be gray-scale values in Mat form.</p>
<p>The inputs to a regular spline are a set of point coordinates, and output is a continuous curve that connects the input points.</p>
<p>In this case, the input would be a set of point coordinates -each with a gray-scale value-. The output would be a smoothed gray-scale contour that covers the entire square Mat.</p>
<p>That was tougher to explain than I expected. Hope it was clear. Perhaps that would actually be a 3D spline in that gray-scale value would be the 3rd dimension. But this is for generating a 2D image.</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=192957#post-id-192957no opencv does not have any splines (or any curve-fitting, which is probably more close to what you wanted.)
also note, that the control points for splines are NOT point coords to be approximated (apart from the 1st and last). [i just saw this](https://www.joshwcomeau.com/posts/dynamic-bezier-curves)Mon, 04 Jun 2018 06:08:17 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=192957#post-id-192957Comment by Martian for <p>Does OpenCV have a method for generating a 2D 'spline' contour? IOW, choose gray-scale pixel values at selected points on a 2D map and have them connected by a smoothed 2-dimensional contour. Output would presumably be gray-scale values in Mat form.</p>
<p>The inputs to a regular spline are a set of point coordinates, and output is a continuous curve that connects the input points.</p>
<p>In this case, the input would be a set of point coordinates -each with a gray-scale value-. The output would be a smoothed gray-scale contour that covers the entire square Mat.</p>
<p>That was tougher to explain than I expected. Hope it was clear. Perhaps that would actually be a 3D spline in that gray-scale value would be the 3rd dimension. But this is for generating a 2D image.</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193215#post-id-193215Reached the comment limit above, so I wanted to add 'thanks.' Please let me know if you have more ideas.Wed, 06 Jun 2018 23:38:05 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193215#post-id-193215Comment by Martian for <p>Does OpenCV have a method for generating a 2D 'spline' contour? IOW, choose gray-scale pixel values at selected points on a 2D map and have them connected by a smoothed 2-dimensional contour. Output would presumably be gray-scale values in Mat form.</p>
<p>The inputs to a regular spline are a set of point coordinates, and output is a continuous curve that connects the input points.</p>
<p>In this case, the input would be a set of point coordinates -each with a gray-scale value-. The output would be a smoothed gray-scale contour that covers the entire square Mat.</p>
<p>That was tougher to explain than I expected. Hope it was clear. Perhaps that would actually be a 3D spline in that gray-scale value would be the 3rd dimension. But this is for generating a 2D image.</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193214#post-id-193214@Berak, I had thought about FFT, and it's on the list of things to try if I can't make this work. I believe I can preserve the objects that I want to keep by doing either bilateral filtering or NLMD, which will smooth the background. At that point, deltas between adjacent background pixels should be minimized. Hence the thought about developing a 2D 'contour' and subtracting it (in every place that the pixel values are close).
I'm not sure if there's a better name for this than spline. I wish I knew that. It would simplify the search.
As for: "you don't give us much to work on, here": What would make this more clear? I thought that the telescope background correction illustrated what I'm trying to do. It's just a more complex version of that, with noise and filmy areas.Wed, 06 Jun 2018 23:36:48 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193214#post-id-193214Comment by sjhalayka for <p>Does OpenCV have a method for generating a 2D 'spline' contour? IOW, choose gray-scale pixel values at selected points on a 2D map and have them connected by a smoothed 2-dimensional contour. Output would presumably be gray-scale values in Mat form.</p>
<p>The inputs to a regular spline are a set of point coordinates, and output is a continuous curve that connects the input points.</p>
<p>In this case, the input would be a set of point coordinates -each with a gray-scale value-. The output would be a smoothed gray-scale contour that covers the entire square Mat.</p>
<p>That was tougher to explain than I expected. Hope it was clear. Perhaps that would actually be a 3D spline in that gray-scale value would be the 3rd dimension. But this is for generating a 2D image.</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193190#post-id-193190Below is a code where I draw a 4-point Bezier curve, and approximate its derivative: Note: The Bezier curve can have as many points as you specify. So, it allows you to produce linear, quadratic, cubic, and beyond:
https://gist.github.com/sjhalayka/d86f5802355dc9bde73fb72dce950d58Wed, 06 Jun 2018 11:26:40 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193190#post-id-193190Comment by berak for <p>Does OpenCV have a method for generating a 2D 'spline' contour? IOW, choose gray-scale pixel values at selected points on a 2D map and have them connected by a smoothed 2-dimensional contour. Output would presumably be gray-scale values in Mat form.</p>
<p>The inputs to a regular spline are a set of point coordinates, and output is a continuous curve that connects the input points.</p>
<p>In this case, the input would be a set of point coordinates -each with a gray-scale value-. The output would be a smoothed gray-scale contour that covers the entire square Mat.</p>
<p>That was tougher to explain than I expected. Hope it was clear. Perhaps that would actually be a 3D spline in that gray-scale value would be the 3rd dimension. But this is for generating a 2D image.</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193035#post-id-193035@Martian, yes, and in this context, your spline idea makes even sense. it's just -- no such thing built in here. maybe you could start easy, and model a simple gaussian distribution. sometimes it's also useful,to do the subtraction in fft space. you could also write highpass / IIR filters which work on 2d space.
but again, what to use where -- it all depends on the context, and you don't give us much to work on, here.Tue, 05 Jun 2018 02:35:05 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193035#post-id-193035Comment by Martian for <p>Does OpenCV have a method for generating a 2D 'spline' contour? IOW, choose gray-scale pixel values at selected points on a 2D map and have them connected by a smoothed 2-dimensional contour. Output would presumably be gray-scale values in Mat form.</p>
<p>The inputs to a regular spline are a set of point coordinates, and output is a continuous curve that connects the input points.</p>
<p>In this case, the input would be a set of point coordinates -each with a gray-scale value-. The output would be a smoothed gray-scale contour that covers the entire square Mat.</p>
<p>That was tougher to explain than I expected. Hope it was clear. Perhaps that would actually be a 3D spline in that gray-scale value would be the 3rd dimension. But this is for generating a 2D image.</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193034#post-id-193034PS: The the filmy looking areas that I referred to do not have precise edges, but adaptive threshold does start looking for any object that it can find in relatively open areas. Otherwise, in areas with actual objects, adaptive thresholding will ignore them. I thought they might be treated similarly to the multi-source lighting quirks, given that deltas are relatively smooth.Tue, 05 Jun 2018 02:34:11 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193034#post-id-193034Comment by Martian for <p>Does OpenCV have a method for generating a 2D 'spline' contour? IOW, choose gray-scale pixel values at selected points on a 2D map and have them connected by a smoothed 2-dimensional contour. Output would presumably be gray-scale values in Mat form.</p>
<p>The inputs to a regular spline are a set of point coordinates, and output is a continuous curve that connects the input points.</p>
<p>In this case, the input would be a set of point coordinates -each with a gray-scale value-. The output would be a smoothed gray-scale contour that covers the entire square Mat.</p>
<p>That was tougher to explain than I expected. Hope it was clear. Perhaps that would actually be a 3D spline in that gray-scale value would be the 3rd dimension. But this is for generating a 2D image.</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193033#post-id-193033Hi Berak, The link that I posted is probably a good example:
http://help.imageanalyst.net/workflow_BackgroundSubtraction.html
But in this case, instead of telescopes, it's microscopes. Same problem though---irregular illumination, but with variations, like haze or filmy looking areas that sometimes gets misinterpreted as objects.
I didn't think I'd find a specific solution to this so I thought I might be able to 'roll my own' with the spline code.Tue, 05 Jun 2018 02:28:24 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193033#post-id-193033Comment by berak for <p>Does OpenCV have a method for generating a 2D 'spline' contour? IOW, choose gray-scale pixel values at selected points on a 2D map and have them connected by a smoothed 2-dimensional contour. Output would presumably be gray-scale values in Mat form.</p>
<p>The inputs to a regular spline are a set of point coordinates, and output is a continuous curve that connects the input points.</p>
<p>In this case, the input would be a set of point coordinates -each with a gray-scale value-. The output would be a smoothed gray-scale contour that covers the entire square Mat.</p>
<p>That was tougher to explain than I expected. Hope it was clear. Perhaps that would actually be a 3D spline in that gray-scale value would be the 3rd dimension. But this is for generating a 2D image.</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193018#post-id-193018^^ k,k, enough ... ;)
@Martian, so the whole talk about splines was pretty misleading. maybe you can show an example image of your problem,and what you're trying to achieve ?
> I have a background field with irregular illumination, somewhat like the telescope image but often more complex. If I could find the general 2D curve for the illumination, I could subtract it to even out the image
that's probably, what the question should have been.Tue, 05 Jun 2018 00:42:39 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193018#post-id-193018Comment by sjhalayka for <p>Does OpenCV have a method for generating a 2D 'spline' contour? IOW, choose gray-scale pixel values at selected points on a 2D map and have them connected by a smoothed 2-dimensional contour. Output would presumably be gray-scale values in Mat form.</p>
<p>The inputs to a regular spline are a set of point coordinates, and output is a continuous curve that connects the input points.</p>
<p>In this case, the input would be a set of point coordinates -each with a gray-scale value-. The output would be a smoothed gray-scale contour that covers the entire square Mat.</p>
<p>That was tougher to explain than I expected. Hope it was clear. Perhaps that would actually be a 3D spline in that gray-scale value would be the 3rd dimension. But this is for generating a 2D image.</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193002#post-id-193002Yes, good luck. :) And spatial distortion (curvature) only explains Newtonian gravity. The addition of time curvature is what makes GR more like reality.Mon, 04 Jun 2018 15:58:38 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193002#post-id-193002Comment by Martian for <p>Does OpenCV have a method for generating a 2D 'spline' contour? IOW, choose gray-scale pixel values at selected points on a 2D map and have them connected by a smoothed 2-dimensional contour. Output would presumably be gray-scale values in Mat form.</p>
<p>The inputs to a regular spline are a set of point coordinates, and output is a continuous curve that connects the input points.</p>
<p>In this case, the input would be a set of point coordinates -each with a gray-scale value-. The output would be a smoothed gray-scale contour that covers the entire square Mat.</p>
<p>That was tougher to explain than I expected. Hope it was clear. Perhaps that would actually be a 3D spline in that gray-scale value would be the 3rd dimension. But this is for generating a 2D image.</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193001#post-id-193001Thanks for the suggestion. I'm not actually working with telescope images. The link illustrated something similar as far as light/illumination correction. It sounds like you're referring to spatial distortion, which I don't need to handle in this case. I have a background field with irregular illumination, somewhat like the telescope image but often more complex. If I could find the general 2D curve for the illumination, I could subtract it to even out the image. Easier said than done.Mon, 04 Jun 2018 15:55:06 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193001#post-id-193001Comment by sjhalayka for <p>Does OpenCV have a method for generating a 2D 'spline' contour? IOW, choose gray-scale pixel values at selected points on a 2D map and have them connected by a smoothed 2-dimensional contour. Output would presumably be gray-scale values in Mat form.</p>
<p>The inputs to a regular spline are a set of point coordinates, and output is a continuous curve that connects the input points.</p>
<p>In this case, the input would be a set of point coordinates -each with a gray-scale value-. The output would be a smoothed gray-scale contour that covers the entire square Mat.</p>
<p>That was tougher to explain than I expected. Hope it was clear. Perhaps that would actually be a 3D spline in that gray-scale value would be the 3rd dimension. But this is for generating a 2D image.</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193000#post-id-193000You could accelerate the light (bend the light's natural, inertial path) using gravitation. Don't forget that the bending of light's path (the bend angle) is double when using General Relativity, versus the old Newtonian gravitation. Not that it makes much difference, but you might as well try to do it right the first time.
http://www.einstein-online.info/spotlights/light_deflection.htmlMon, 04 Jun 2018 15:45:42 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193000#post-id-193000Comment by Martian for <p>Does OpenCV have a method for generating a 2D 'spline' contour? IOW, choose gray-scale pixel values at selected points on a 2D map and have them connected by a smoothed 2-dimensional contour. Output would presumably be gray-scale values in Mat form.</p>
<p>The inputs to a regular spline are a set of point coordinates, and output is a continuous curve that connects the input points.</p>
<p>In this case, the input would be a set of point coordinates -each with a gray-scale value-. The output would be a smoothed gray-scale contour that covers the entire square Mat.</p>
<p>That was tougher to explain than I expected. Hope it was clear. Perhaps that would actually be a 3D spline in that gray-scale value would be the 3rd dimension. But this is for generating a 2D image.</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=192999#post-id-192999I ran across a good illustration of what I'm looking for in the long run. This shows removal of 'curved' background illumination for a telescope image:
http://help.imageanalyst.net/workflow_BackgroundSubtraction.html
Unfortunately, that's a specialized commercial program. And I'm looking for something that could adapt to more complex 2D 'light curvatures.' That's why I had envisioned a spline. But perhaps there are other approaches.Mon, 04 Jun 2018 15:40:55 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=192999#post-id-192999Comment by Martian for <p>Does OpenCV have a method for generating a 2D 'spline' contour? IOW, choose gray-scale pixel values at selected points on a 2D map and have them connected by a smoothed 2-dimensional contour. Output would presumably be gray-scale values in Mat form.</p>
<p>The inputs to a regular spline are a set of point coordinates, and output is a continuous curve that connects the input points.</p>
<p>In this case, the input would be a set of point coordinates -each with a gray-scale value-. The output would be a smoothed gray-scale contour that covers the entire square Mat.</p>
<p>That was tougher to explain than I expected. Hope it was clear. Perhaps that would actually be a 3D spline in that gray-scale value would be the 3rd dimension. But this is for generating a 2D image.</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=192998#post-id-192998Thanks for the helpful replies. I'm surprised that OpenCV has no built in functions for this. I've seen mention of correcting camera spatial distortion, so I thought this would be related.
OpenCV does have adaptive thresholding, but that goes wrong in areas where there are no foreground objects for contrast. It will detect the more pronounced areas of noise as foreground.Mon, 04 Jun 2018 15:39:27 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=192998#post-id-192998Comment by sjhalayka for <p>Does OpenCV have a method for generating a 2D 'spline' contour? IOW, choose gray-scale pixel values at selected points on a 2D map and have them connected by a smoothed 2-dimensional contour. Output would presumably be gray-scale values in Mat form.</p>
<p>The inputs to a regular spline are a set of point coordinates, and output is a continuous curve that connects the input points.</p>
<p>In this case, the input would be a set of point coordinates -each with a gray-scale value-. The output would be a smoothed gray-scale contour that covers the entire square Mat.</p>
<p>That was tougher to explain than I expected. Hope it was clear. Perhaps that would actually be a 3D spline in that gray-scale value would be the 3rd dimension. But this is for generating a 2D image.</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=192970#post-id-192970The easiest curved line is the Bezier curve:
https://en.wikipedia.org/wiki/Bézier_curve#Quadratic_Bézier_curves
It takes 3D points and interpolates between them. I once used Bezier curves to visualize the quaternions as they are operated on, using Z = Z*Z + C as the iterated equation. If you perform intersection of the curve and the quaternion fractal's surface, you can get a normal (derivative) at the intersection point.Mon, 04 Jun 2018 10:33:17 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=192970#post-id-192970Comment by berak for <p>Does OpenCV have a method for generating a 2D 'spline' contour? IOW, choose gray-scale pixel values at selected points on a 2D map and have them connected by a smoothed 2-dimensional contour. Output would presumably be gray-scale values in Mat form.</p>
<p>The inputs to a regular spline are a set of point coordinates, and output is a continuous curve that connects the input points.</p>
<p>In this case, the input would be a set of point coordinates -each with a gray-scale value-. The output would be a smoothed gray-scale contour that covers the entire square Mat.</p>
<p>That was tougher to explain than I expected. Hope it was clear. Perhaps that would actually be a 3D spline in that gray-scale value would be the 3rd dimension. But this is for generating a 2D image.</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=192960#post-id-192960https://en.wikipedia.org/wiki/Curve_fittingMon, 04 Jun 2018 08:36:28 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=192960#post-id-192960Answer by berak for <p>Does OpenCV have a method for generating a 2D 'spline' contour? IOW, choose gray-scale pixel values at selected points on a 2D map and have them connected by a smoothed 2-dimensional contour. Output would presumably be gray-scale values in Mat form.</p>
<p>The inputs to a regular spline are a set of point coordinates, and output is a continuous curve that connects the input points.</p>
<p>In this case, the input would be a set of point coordinates -each with a gray-scale value-. The output would be a smoothed gray-scale contour that covers the entire square Mat.</p>
<p>That was tougher to explain than I expected. Hope it was clear. Perhaps that would actually be a 3D spline in that gray-scale value would be the 3rd dimension. But this is for generating a 2D image.</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?answer=193630#post-id-193630well, 2 ideas here:
one could generate a heightmap from x and y curves, like in this silly drawing:
![image description](/upfiles/15287929238855809.png)
and the resulting intensity distribution would be simply the outer product of the curves:
Mat intensity = curve_x * curve_y.t();
(and that's also where the 2d splines are back !)
##-------------------------------------------------------
but also, your background noise is basically a gaussian distribution. (or maybe a mix of gaussians), so probably a simple mouse painting tool (where you subtract such blobs on every click) might do the trick already:
![image description](/upfiles/1528793206835002.png)
#include<opencv2/opencv.hpp>
#include<iostream>
using namespace cv;
using namespace std;
Mat gauss_blob(int siz, float sig) {
Mat k = getGaussianKernel(siz*2+1, sig, CV_32F);
return k*k.t();
}
int border=800; // max kernel size
int t_int = 220;
int t_sig = 200;
int t_siz = 100;
Mat img;
void on_mouse(int e, int x, int y, int s, void*) {
if (e==1) {
Rect r(border+x-t_siz, border+y-t_siz, 2*t_siz+1, 2*t_siz+1);
Mat patch(img,r);
Mat blob = gauss_blob(t_siz, float(t_sig)/10);
patch -= t_int * blob;
}
if (e==2) ;// r-click, *add* the blob for undo.
}
int main(void) {
img = imread("stars.png", 0);
img.convertTo(img, CV_32F, 1.0/255);
// make sure we stay inside the image
Rect show(border,border,img.cols,img.rows);
copyMakeBorder(img,img,border,border,border,border,BORDER_CONSTANT,Scalar(0));
namedWindow("gauss");
createTrackbar("size", "gauss", &t_siz, 800);
createTrackbar("sigma", "gauss", &t_sig, 800);
createTrackbar("intensity", "gauss", &t_int, 500);
setMouseCallback("gauss", on_mouse);
while(1) {
imshow("gauss", img(show));
if (waitKey(5) == 27) break;
}
return(0);
}
Tue, 12 Jun 2018 03:50:30 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?answer=193630#post-id-193630Comment by sjhalayka for <p>well, 2 ideas here:</p>
<p>one could generate a heightmap from x and y curves, like in this silly drawing:</p>
<p><img alt="image description" src="/upfiles/15287929238855809.png"></p>
<p>and the resulting intensity distribution would be simply the outer product of the curves:</p>
<pre><code>Mat intensity = curve_x * curve_y.t();
</code></pre>
<p>(and that's also where the 2d splines are back !)</p>
<h2>-------------------------------------------------------</h2>
<p>but also, your background noise is basically a gaussian distribution. (or maybe a mix of gaussians), so probably a simple mouse painting tool (where you subtract such blobs on every click) might do the trick already:</p>
<p><img alt="image description" src="/upfiles/1528793206835002.png"></p>
<pre><code>#include<opencv2/opencv.hpp>
#include<iostream>
using namespace cv;
using namespace std;
Mat gauss_blob(int siz, float sig) {
Mat k = getGaussianKernel(siz*2+1, sig, CV_32F);
return k*k.t();
}
int border=800; // max kernel size
int t_int = 220;
int t_sig = 200;
int t_siz = 100;
Mat img;
void on_mouse(int e, int x, int y, int s, void*) {
if (e==1) {
Rect r(border+x-t_siz, border+y-t_siz, 2*t_siz+1, 2*t_siz+1);
Mat patch(img,r);
Mat blob = gauss_blob(t_siz, float(t_sig)/10);
patch -= t_int * blob;
}
if (e==2) ;// r-click, *add* the blob for undo.
}
int main(void) {
img = imread("stars.png", 0);
img.convertTo(img, CV_32F, 1.0/255);
// make sure we stay inside the image
Rect show(border,border,img.cols,img.rows);
copyMakeBorder(img,img,border,border,border,border,BORDER_CONSTANT,Scalar(0));
namedWindow("gauss");
createTrackbar("size", "gauss", &t_siz, 800);
createTrackbar("sigma", "gauss", &t_sig, 800);
createTrackbar("intensity", "gauss", &t_int, 500);
setMouseCallback("gauss", on_mouse);
while(1) {
imshow("gauss", img(show));
if (waitKey(5) == 27) break;
}
return(0);
}
</code></pre>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=195703#post-id-195703@berak -- Please check out this new Bezier curve screenshot: https://github.com/sjhalayka/random_images/blob/master/ZPOW4.pngSat, 14 Jul 2018 22:41:09 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=195703#post-id-195703Answer by sjhalayka for <p>Does OpenCV have a method for generating a 2D 'spline' contour? IOW, choose gray-scale pixel values at selected points on a 2D map and have them connected by a smoothed 2-dimensional contour. Output would presumably be gray-scale values in Mat form.</p>
<p>The inputs to a regular spline are a set of point coordinates, and output is a continuous curve that connects the input points.</p>
<p>In this case, the input would be a set of point coordinates -each with a gray-scale value-. The output would be a smoothed gray-scale contour that covers the entire square Mat.</p>
<p>That was tougher to explain than I expected. Hope it was clear. Perhaps that would actually be a 3D spline in that gray-scale value would be the 3rd dimension. But this is for generating a 2D image.</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?answer=193288#post-id-193288OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:
http://paulbourke.net/geometry/bezier/
The function is:
![image description](/upfiles/15293540761744061.gif)
The function leads to 2D curved surfaces in 3D space:
![image description](/upfiles/15295416088433723.png)
I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).
The code is at:
https://github.com/sjhalayka/bezier_to_mat
The result is a blurry mess. For instance, the input is 512 x 384:
![image description](/upfiles/15296975706739387.jpg)
And the output is 64x64:
![image description](/upfiles/1529697625290594.png)
You see the main problem now, eh? It's still too smooth?Thu, 07 Jun 2018 11:00:28 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?answer=193288#post-id-193288Comment by Martian for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=195523#post-id-195523Hi SJ, Just noticed your recent comment. The goal is to simply the background of an image so that functions like 'adaptiveThreshold' will not mis-trigger on noise (the dark gradients). It may prove useful elsewhere, I'm not sure. Thanks again for the effort that you put into this. Quite cool to see it take shape!Wed, 11 Jul 2018 16:50:57 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=195523#post-id-195523Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=195112#post-id-195112@Martian -- are you using the code as a way to compress the image data?Thu, 05 Jul 2018 14:30:30 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=195112#post-id-195112Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194481#post-id-194481I updated the bezier_to_mat code (https://github.com/sjhalayka/bezier_to_mat) so that there is no need to call `mp_to_int()`. This can only improve the efficiency of the algorithm.
I also added a main.h file.
I have also removed the `fact()` function, and so the `binomial()` function uses the factorial LUT directly. The change in syntax is a simple one.Mon, 25 Jun 2018 10:40:32 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194481#post-id-194481Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194417#post-id-194417It is indeed a valuable component! The simplicity of the optimization makes it a clever idea. I added it to the bezier_to_mat code. Give me a little time to get it into the other two projects. I consider these other two projects to be less than important now that I know what you were looking for. :)
Are you on GitHub? You can always create a new repository based off of one of my repositories!Sat, 23 Jun 2018 21:51:42 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194417#post-id-194417Comment by Martian for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194416#post-id-194416@SJ: I was just wondering why it was separate from the Github projects. If it works well, it seems like it could be a valuable component. --- I could tell that you were having fun coding this. Very cool to watch how it evolved. I'm sure others will appreciate it as well.Sat, 23 Jun 2018 21:34:44 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194416#post-id-194416Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194414#post-id-194414@Martian — I didn’t think you cared either way, but I will indeed add your LUT to the main bezier_to_mat code. I will also work at adding it to the other two projects.
Well I hope this tool does what you need it to, and that it becomes widely used. It was fun to code; kept me entertained. LOLSat, 23 Jun 2018 21:16:31 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194414#post-id-194414Comment by Martian for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194411#post-id-194411Hi SJ, Q: Is there a reason why you didn't incorporate the factorial LUT module directly into the Github projects?
A: My background is in both computers and biosciences. I'm not a biologist per se, but I have studied aspects. It's helpful to know what's going on.Sat, 23 Jun 2018 20:47:37 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194411#post-id-194411Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194407#post-id-194407@Martian -- are you a biologist?Sat, 23 Jun 2018 18:11:29 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194407#post-id-194407Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194352#post-id-194352@Martian -- I implemented your factorial look up table (LUT). Not sure how much faster it runs:
https://gist.github.com/sjhalayka/16fe33f2f9399237effbfada7e61b2c2
I read some documentation that says that the find function for a std::map runs in O(ln n) time. Using the LUT, the std::vector [] operator runs in O(1) time. So there's a benefit right there...Fri, 22 Jun 2018 18:45:16 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194352#post-id-194352Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194338#post-id-194338@Martian — yes it was an interesting evolution from 1D to 2D. I had never done 2D Bézier surfaces before, so it was a learning experience for me!
And I forgot to mention that the code I wrote is in the public domain, so you can do whatever you want with it, and you don't need to give me credit. It's free.Fri, 22 Jun 2018 14:47:52 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194338#post-id-194338Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194283#post-id-194283@Martian -- Thanks for the extra karma, it's much appreciated. I'm glad you like the results, and thanks to you for your patience while I figured out what you were asking for. Your idea about using a lookup table (vector) is a great one, and likely faster than the map-based lookup that I use in my version of the code.Thu, 21 Jun 2018 22:58:53 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194283#post-id-194283Comment by Martian for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194281#post-id-194281And SJ: Profuse thanks for the outstanding effort. That was interesting watching that take shape.
BTW, it seems like it would be possible to pre-compute all the factorials up to N, then just index into the lookup table...right? I wonder how that's done in commercial surface fitting software.Thu, 21 Jun 2018 22:17:53 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194281#post-id-194281Comment by Martian for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194280#post-id-194280Hi SJ:
1: Mark as correct: Sure thing. ---
2: Neural nets: Not sure if I follow there. The weights in a NN do form a sort of terrain map, but it's multidimensional, so it would be -really- expensive to compute. That's why the normal approach is to find the gradient at the current local spot, and work incrementally from there. ---
3: What: Trying to cancel out background in microscope images, but that could conceivably work with any type of image that had background noise, uneven lighting, etc.Thu, 21 Jun 2018 22:14:53 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194280#post-id-194280Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194276#post-id-194276@Martian — may I ask what you’re doing with the interpolation software?Thu, 21 Jun 2018 20:26:21 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194276#post-id-194276Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194270#post-id-194270@Martian -- makes me wonder if there's room in the world for neural networks that are based on Bezier surfaces. Just a thought.Thu, 21 Jun 2018 18:17:42 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194270#post-id-194270Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194251#post-id-194251@Martian -- Glad to hear that you're happy with the results. If you can, please mark my answer as correct.Thu, 21 Jun 2018 11:56:24 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194251#post-id-194251Comment by Martian for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194211#post-id-194211Hi SJ, I don't think there's a problem with the image being 'too blurry.' It looks like it's working! It would get more clear as the number of points increases. --- As for the number of digits in the factorial op, I'm not sure there's any way around doing the factorial if an exact number is required. But since adding logs is equivalent to multiplying numbers, it's basically about adding log 2 + log 3 + log 4... to get log 4! Perhaps that concept could be used with some caching scheme.Thu, 21 Jun 2018 00:57:57 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194211#post-id-194211Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194200#post-id-194200@Martian -- I was looking to get the number of digits used by the factorial function without having to call the factorial function itself.Wed, 20 Jun 2018 17:28:09 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194200#post-id-194200Comment by Martian for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193613#post-id-193613You've really gone out of your way for this. Very much appreciated! I'm not sure what that is doing though. It appears to work only on a local set of four surrounding pixels, and I'm not sure what the output gives in relation to the original problem. I think the solution needs to smoothly interpolate between a larger group of pixels (x,y,z coords) to develop the gradual hills/valleys. Then I could just change z to a pixel intensity.
I've seen toolkits for doing Nurbs and T-Splines for surfaces, and I could probably adapt something like that if I had time. But I was hoping to find that there was an existing surface-modeling library that would be close enough to OpenCV that it would be easy to adapt.Tue, 12 Jun 2018 01:34:12 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193613#post-id-193613Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194180#post-id-194180@Martian -- I took down the images that weren't required anymore. I just added the input and output images that I used to test the new code. The new code generates a Mat instead of rendering it to the screen. Hopefully it's closer to what you were looking for in an answer? Thanks for the tips on the factorial function! Yes, the log math is relevant when determining how many bits (output neurons in a neural network) one needs given a certain number of classifications, if you're not using one-hot encoding, that is.Wed, 20 Jun 2018 12:33:47 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194180#post-id-194180Comment by Martian for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194128#post-id-194128For some reason, I'm not seeing many of the images that you've posted here, SJ. Did you post an image that you generated? ----------
Also, re the factorial precision question: If you're implementing the equations listed at the top, they look like the factorials in numerator and denominator could be simplified ahead of time, which could reduce the numeric precision needed. Simple example: 5! / 3! = 5 x 4. So you wouldn't need the full precision of 5!
And that counts with high factorial numbers. Probably faster too..Wed, 20 Jun 2018 00:12:41 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194128#post-id-194128Comment by Martian for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194127#post-id-194127SJ: The images are about 1000 x 1000. I'd sample at, say, 64 x 64 by averaging pixels and discarding those the probably belong to foreground objects. So I'd end up with various gray tones on a 64 x 64 grid (possibly missing some, if foreground objects are in the way). The goal would be to generate a smooth gray-scale contour that conforms to those samples. As for touching the exact sample values: Possibly that could be made closer by increasing the number of samples.Wed, 20 Jun 2018 00:02:34 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194127#post-id-194127Comment by Martian for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194126#post-id-194126re: "does anyone know the math to tell you how many digits of precision are needed for the answer to factorial(n)?"
You mean like a log function? If you're referring to decimal digits, it should be log10(factorial(n)), right? Or maybe I am missing what you're talking about. If it is bits, then it's log base 2, which can be computed as log10(n) / log10(2). For example, 1024 is 2^10. log10(1024) = 3.0103. That's over 3, so you'd need to round up: It requires 4 digits. To find the number of bits: log10(1024) / log10(2) = 3.0103 / 0.30103 = 10 bits.Tue, 19 Jun 2018 23:57:53 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194126#post-id-194126Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194125#post-id-194125@berak and @Martian -- I updated the answer. I now perform the enlargement of an image (and nothing else). It simply outputs a .png file. The code is in one file, that's how small it is. No OpenGL required. The results are a blurry mess.Tue, 19 Jun 2018 22:22:13 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194125#post-id-194125Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194109#post-id-194109@Martian -- So, let me get this straight... you're taking in a small, say, 64x64 input image and converting it to a large output image, say, 1024x1024? You're using curved surfaces as a way to interpolate when upsizing the image?
Sorry again, I’m not the sharpest tool in the shed. Thanks for your patience while the answer morphs closer and closer to being correct.
I think that Bézier B(u, v) and NURBS N(u, v) surfaces aren’t going to work after all: the surfaces doesn’t generally go through the control points. Is that not what you required? Or are you willing to relax that requirement? If so then making a Mat by sampling B(u, v) will be straightforward. I won’t bother implementing N(u, v), that’s up to you.Tue, 19 Jun 2018 16:59:04 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194109#post-id-194109Comment by berak for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194099#post-id-194099@sjhalayka that's all *supercool* !
may i remind you though, that in the end it needs *an image* , (that can be subtracted from the original) ? ;)Tue, 19 Jun 2018 11:36:09 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194099#post-id-194099Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194097#post-id-194097@Martian -- I added in a cache feature for the factorial and binomial functions when generating Bezier surfaces. It runs a little bit fasterTue, 19 Jun 2018 11:16:29 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194097#post-id-194097Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194095#post-id-194095@Martian @berak -- does anyone know the math to tell you how many digits of precision are needed for the answer to factorial(n)?Tue, 19 Jun 2018 10:56:45 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194095#post-id-194095Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194050#post-id-194050Sorry for the confusion... none of these renders were generated using glEvalMesh2. They’re all generated by my own code. :)
Ok, if you're planning on using 64x64 images, then the 100-digit precision floats should be big enough.
And, you’re welcome!!!
If you end up implementing NURBS then please come back here and answer your own question. Good luck!!!!Mon, 18 Jun 2018 17:31:53 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194050#post-id-194050Comment by Martian for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194049#post-id-194049Hi again, SJ. I see there's a new image that has curved surfaces. I didn't see that before. Is that your code, or is it the OpenGL glEvalMesh2 function that you referred to?
For my app, the images are usually 1000x1000, but I don't need a control point for every pixel. I was hoping to average pixels within a certain area to derive each control point, and then let the surface fit function find a gradually changing surface that conforms. I'd probably use about 64 x 64 control points, maybe less. But unfortunately, due to the foreground objects, I wouldn't be able to supply a control point for each. They'd be irregular, with some missing points.
Re "Mission aborted": You've done some cool stuff here, so much appreciated either way!Mon, 18 Jun 2018 17:18:59 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194049#post-id-194049Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194040#post-id-194040@berak -- mission aborted. I managed to implement Bezier surfaces, but the processing time prohibits use of relatively large images, which could take hours, days, months (like, 1024x1024 pixels). The same would go for NURBS surfaces as well, which are like Bezier surfaces, but with a knot vector. I did not implement NURBS surfaces because of this inherent gigantic time complexity.
A linear version of the surface produces a useful approximation to a curved surface, and takes only seconds to compute, versus hours, days, months.Mon, 18 Jun 2018 15:21:40 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194040#post-id-194040Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194034#post-id-194034@Martian -- It would be optimal if the triangles were smaller than a pixel in size... lots of triangles, the more the better. :DMon, 18 Jun 2018 12:17:52 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=194034#post-id-194034Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193989#post-id-193989@Martian -- Yep, the triangles have straight edges. To approximate the surface better and better, one makes the triangles smaller and smaller. This can be achieved by altering the spacer variable in main.cpp (all the pertinent code exists in main.cpp). The smaller the spacer, the smaller the triangles. In any case, when it comes to rendering the surface, triangles are what's required by OpenGL. You could draw a Bezier surface using [glEvalMesh2](http://www.glprogramming.com/red/chapter12.html), but you don't get control over the normals or colours of the vertices, which is why we have to use triangles.
When you get around to compiling the code, you will find that a spacer of 0.01 for a 64x48 image takes up a good hour on the CPU. Images like 1024x1024 would take days or months.Sun, 17 Jun 2018 22:46:37 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193989#post-id-193989Comment by Martian for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193988#post-id-193988Hi again SJ, I'll have to look further into Boost and OpenGL. It seems like it could be useful if I'm working in 3D.
Re the picture: Maybe it's me, but that looks like straight lines connecting the points....?Sun, 17 Jun 2018 22:23:56 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193988#post-id-193988Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193971#post-id-193971@Martian -- I posted the code for Bezier surfaces in C++ in the answer. Note that the Bezier surfaces blows up when using long double and long long int, because they’re not large enough. So, one needs arbitrary-sized float libraries to use Bézier aurfaces, and that’s where Boost multi precision comes into play. It’s pretty straightforward. Download the Boost libraries .zip file and copy the boost directory into your compiler’s include directory. Then compile my code.Sun, 17 Jun 2018 11:35:48 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193971#post-id-193971Comment by Martian for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193903#post-id-193903Hi sj,
Yes, I'm working in C++ for this, so I do follow what you've posted so far. Surface fitting is the term that is often used to describe this type of thing. Just like curve-fitting for points in 2D. Surface fitting for points in 3D.Sat, 16 Jun 2018 00:50:31 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193903#post-id-193903Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193885#post-id-193885@Martian — I never thought to ask... is C++ your language of choice?
What do you mean by surface fitting?
I’m a little slow on the uptake sometimes.Fri, 15 Jun 2018 14:50:21 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193885#post-id-193885Comment by Martian for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193838#post-id-193838You're probably more up to speed on knot vectors, than I. I'm not sure how knot vectors would affect final output, but Bezier may be good enough. I presume that most 'surface fitting' is Bezier.Thu, 14 Jun 2018 21:20:28 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193838#post-id-193838Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193837#post-id-193837@Martian -- There sure is a lot more documentation for Bezier surfaces than there is for NURBS surfaces. From what I can tell, the only difference between a NURBS surface and a Bezier surface is the knot vector. I am having trouble conceptualizing what the knot vector does. Do you have any insight into this?
Are Bezier surfaces good enough? This document shows exactly how to do it in one function: http://paulbourke.net/geometry/bezier/Thu, 14 Jun 2018 20:55:22 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193837#post-id-193837Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193775#post-id-193775@Martian -- Perhaps this is going to be good enough? What do you think about: http://paulbourke.net/geometry/spline/Wed, 13 Jun 2018 22:14:34 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193775#post-id-193775Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193768#post-id-193768@Martian — it seems like it’s just for display, since you can’t recover the triangles used to tesselate the curved surface. That is to say that converting the surface to triangles is the ultimate goal.
It looks like you’re going to have to pick a NURBS library.
Let me know if you run into trouble.Wed, 13 Jun 2018 19:48:05 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193768#post-id-193768Comment by Martian for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193767#post-id-193767Very cool! I haven't looked at OpenGL for a long while, so I'll have to get up to speed. Is it used just for display, or do you normally write spline code using OpenGL functions?Wed, 13 Jun 2018 19:37:38 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193767#post-id-193767Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193755#post-id-193755@Martian -- I got Bezier surfaces working in OpenGL, with an arbitrary number of control points! 5x4 in this case. Here's a tiny code:
https://gist.github.com/sjhalayka/e1b281fdef2982c8338345ffce2a21a4
I'll look into NURBS surfaces next.Wed, 13 Jun 2018 13:30:21 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193755#post-id-193755Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193676#post-id-193676@Martian -- Hey, no problem! The output is a version of this picture: https://i.ytimg.com/vi/6w1w_Hxvwhs/maxresdefault.jpg
Sorry, I forgot to mention that. :( I updated the code and the output screenshot. Hopefully it's a lot easier to make out now.
If you pick a NURBS library, let me know. I will try to code up a curved version.Tue, 12 Jun 2018 21:33:19 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193676#post-id-193676Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193578#post-id-193578@Martian -- Are you at all familiar with OpenGL? This is just for reference: http://www.glprogramming.com/red/chapter12.html
So basically you're looking for a height map, where the intensity is related to the height?
I altered my answer to give you a linear solution. Try that before moving on to curved surfaces -- the OpenGL code I linked to shows you how to get curved surfaces.Mon, 11 Jun 2018 10:47:02 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193578#post-id-193578Comment by Martian for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193526#post-id-193526Not a curved line, a curved plane. Start by looking at it as a terrain map, with hills and valleys. If the elevation is then translated into a luminance value, that would look like the gradual shifts in the backgrounds of the images above.
This seems way more difficult to explain than I had envisioned. I had always heard this referred to as a 2D spline, and I believe it is used in exactly this context (background removal in microscope images). So I thought it was common terminology.Sun, 10 Jun 2018 22:15:09 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193526#post-id-193526Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193520#post-id-193520@Martian -- how do curved lines play a role in this? Can you make a sample image with the curved line? Like, make it in GINP.Sun, 10 Jun 2018 17:59:59 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193520#post-id-193520Comment by Martian for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193470#post-id-193470The background of these images shows the type of noise that is difficult to reject:
https://www.researchgate.net/profile/Andreas_Burkovski/publication/318286147/figure/fig3/AS:514447957807104@1499665359173/Fluorescence-microscopy-of-C-elegans-colonization-Nematodes-infected-with-bacteria-were.png
Again, that can be pre-filtered with NLMD or whatever, which leaves blurred irregular areas. Those are often rejected, except when there are no nearby objects, in which case they are falsely detected as objects by adaptiveThreshold.Sat, 09 Jun 2018 22:02:29 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193470#post-id-193470Comment by Martian for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193469#post-id-193469Glad that you're interested, sjh. It sounds like you've done a lot of work with splines and graphics.
Below are a few images showing problems that I referred to.
This shows a very simple, gradual shift in background tone:
http://genesdev.cshlp.org/content/12/4/571/F5/graphic-10.large.jpg
Ordinarily, adaptiveThreshold will reject that, but if there are no objects in foreground, it starts looking for anything it can find, and ends up detecting peaks in dark/light even if the shift is gradual. This would be a prime example, as you can see that a slowly shifting contour could be subtracted to leave the background completely flat.
This image is tougher, but could possibly be handled after pre-processing w nlmd or bilateral filtering:
https://i.ytimg.com/vi/6w1w_Hxvwhs/maxresdefault.jpgSat, 09 Jun 2018 21:56:30 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193469#post-id-193469Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193409#post-id-193409@Martian -- do you have a sample of what you want done? I'm not sure I'm catching your drift.Fri, 08 Jun 2018 14:53:40 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193409#post-id-193409Comment by berak for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193292#post-id-193292i sincerely do. ;)
now go, and solve *the problem*, lol ;)
your task (if you choose to accept it) would be to model a 2d hyperplane/volume in 3d(x,y,intensity) space, that models additional/artificial lightsources, so those can easily be subtracted from an existing 3d profile (aka- the image)
this message will burn itself in 5 minutes.Thu, 07 Jun 2018 12:02:06 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193292#post-id-193292Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193294#post-id-193294Haha, let me see about it.Thu, 07 Jun 2018 12:42:51 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193294#post-id-193294Comment by berak for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193289#post-id-193289that's entirely cool, but required was a 2d hyperplane in 3d space ! (x,y,intensity)
(even if it wasn't sooo clear in the question)Thu, 07 Jun 2018 11:08:41 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193289#post-id-193289Comment by sjhalayka for <p>OK, now that it's decided that Bezier surfaces might be good enough, here is a link to the function that needs to be implemented:</p>
<p><a href="http://paulbourke.net/geometry/bezier/">http://paulbourke.net/geometry/bezier/</a></p>
<p>The function is:</p>
<p><img alt="image description" src="/upfiles/15293540761744061.gif"></p>
<p>The function leads to 2D curved surfaces in 3D space:</p>
<p><img alt="image description" src="/upfiles/15295416088433723.png"></p>
<p>I’ve implemented the function. When the number of control points spirals upward, so does the amount of computation and variable precision needed. Loading a 1024x1024 image would be only for the very patient. I had to use the Boost multi precision library, with 100 digits, because long long unsigned int and long double were not big enough. If you find that this answer is suitable, please mark it as correct (click on the checkmark).</p>
<p>The code is at:</p>
<p><a href="https://github.com/sjhalayka/bezier_to_mat">https://github.com/sjhalayka/bezier_t...</a></p>
<p>The result is a blurry mess. For instance, the input is 512 x 384:</p>
<p><img alt="image description" src="/upfiles/15296975706739387.jpg"></p>
<p>And the output is 64x64:</p>
<p><img alt="image description" src="/upfiles/1529697625290594.png"></p>
<p>You see the main problem now, eh? It's still too smooth?</p>
http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193290#post-id-193290OK cool. Glad you liked my shaggy fractal. :)Thu, 07 Jun 2018 11:14:14 -0500http://answers.opencv.org/question/192956/2d-spline-algorithm-in-opencv/?comment=193290#post-id-193290