Required to turn an image into N triangles with Delaunay triangulation. One color for each triangle, and colors can be repeated.
The loss function is given by the square of the difference in the color of each pixel.
So how to optimize the color and the vertices of triangles?
A recursive splitting procedure outline:
Terminate the recursion if N < 2
Split the given area A in two triangles A1 and A2 in such a way that the
sum of standard deviations of the pixel colors is cut in halves.
Assign N/2 colors to A1 and N - N/2 colors to A2.
Recursively split A1 and A2.
The resulting net of N triangles is colored to minimize the loss function:
For every triangle the color chosen is the average color of the pixels within that triangle.
It might be worthwhile to conduct a survey of existing literature on the topic. A first search engine hit returned Fractal image compression based on Delaunay triangulation and vector quantization
Good afternoon,
I'm quite new to VBA and Excel and i'm having the following problem.
I have a function that requires a symmetric matrix as input to calculate the eigenvalue [=MEigenvalueMax (A1: C3)]. However, I have the data for the matrix in different cells. My question is therefore whether there is a function with which I can define predefined cells as a matrix, e. g. =MEigenvalMax ({A1, A2, A3; B1, B2, B3; C1, C2, C3}).
Thank you for the answers!
to fill an array with range values you simply go like follows:
Dim eigenvalueMatrix As Variant
eigenvalueMatrix = Range("A1:C3").Value
Suppose I know the solution to the problem:
max f(x)
s.t x in conv{a1, a2, ..., an}
where f is a convex function. It is well known that an optimal solution to this problem lies on one of the extreme points of the convex hull of {a1, a2, ..., an}.
My question is the following. Suppose I pertub the convex hull with the following perubation:
ak <- ak + c.
What would be the demands on c and f so that the optimal extreme point solution (w.r.t the order of the ai) does not change? In other words, when changing the constraints by a bit I don't want the solution to jump off to a completely different place and would expect it to stay.
I have created the 3D mesh. I just wonder whether I can search for the adjacent cells for one special cell.
Given a Cell_handle, you can access its neighbors cells using the neighbor function:
Cell_handle n = cell->neighbor(i); // 0<= i < 4
If you want to restrict to cells in the complex, you can use the function is_in_complex(Cell_handle c).
Based on the following resources, I have been trying to get resolution independent cubic bezier rendering on the GPU to work:
GPU Gems 3 Chapter 25
Curvy Blues
Resolution Independent Curve Rendering using Programmable Graphics Hardware
But as stated in the Curvy Blues website, there are errors in the documents on the other two websites. Curvy Blues tells me to look at the comments, but I don't seem to be able to find those comments. Another forum somewhere tells me the same, I don't remember what that forum was. But there is definitely something I am missing.
Anyway, I have tried to regenerate what is happening and I fail to understand the part where the discriminant is calculated from the determinants of a combination of transformed coordinates.
So I have the original coordinates, I stick them in a 4x4 matrix, transform this matrix with the M3-matrix and get the C-matrix.
Then I create 3x3 matrices from the coordinates in the C-matrix and calculate the determinants, which then can be combined to create the a, b and c of the quadratic equation that will help me find the roots.
Problem is, when I do it exactly like that: the discriminant is incorrect. I clearly put in coordinates for a serpentine (a symmetric one, but a correct serpentine), but it states it is a cusp.
When I calculate it myself using wxMaxima, deriving to 1st and 2nd order and then calculating the cross-product, simplifying to a quadratic equation, the discriminant of that equation seems to be correct when I put in the same coordinates.
When I force the code to use my own discriminant to determine if it's a serpentine or not, but I use the determinants to calculate the further k,l,m texture coordinates, the result is also incorrect.
So I presume there must be an error in the determinants.
Can anyone help me get this right?
I think I have managed to solve it. The results are near to perfect (sometimes inverted, but that's probably a different problem).
This is where I went wrong, and I hope I can help other people to not waste all the time I have wasted searching this.
I have based my code on the blinn-phong document.
I had coordinates b0, b1, b2, b3. I used to view them as 2D coordinates with a w, but I have changed this view, and this solved the problem. By viewing them as 3D coordinates with z = 0, and making them homogenous 4D coordinates for transformation (w = 1), the solution arrived.
By calculating the C matrix: C = M3 * B, I got these new coordinates.
When calculating the determinants d0, d1, d2, d3, I used to take the x, y coordinates from columns 0 and 1 in the C matrix, and the w factor from column 2. WRONG! When you think of it, the coordinates are actually 3D coordinates, so, for the w-factors, one should take column 3 and ignore column 2.
This gave me correct determinants, resulting in a discriminant that was able to sort out what type of curve I was handling.
But beware, what made my search even longer was the fact that I assumed that when it is visibly a serpentine, the result of the discriminant should always be > 0 (serpentine).
But this is not always the case, when you have a mathematically perfect sepentine (coordinates are so that the mean is exact middle), the determinant will say it's a cusp (determinant = 0). I used to think that this result was wrong, but it isn't. So don't be fooled by this.
The book GPU Gem 3 has a mistake here, and the page on nVidia's website has the mistake too:
a3 = b2 * (b1 x b1)
It's actually a3 = b2 * (b1 x b0).
There're other problems about this algorithm: the exp part of the floating point will overflow during the calculation, so you should be cautious and add normalize operations into your code.