•      Sign In
• Create Account

# datahead8888

Member Since 03 Oct 2007
Offline Last Active Nov 26 2013 07:35 PM

### Using the product rule for a partial derivative of a vector/matrix function...

24 November 2013 - 01:28 PM

I was working on a physics animation, and I need to compute the Jacobian in order to solve a partial differential equation.

Suppose we have a function consisting of a series of matrices multiplied by a vector:
f(X) = A * B * b
--where X is a vector containing elements that are contained within A, b, and/or b,
--A is a matrix, B is a matrix, and b is a vector

Each Matrix and the vector is expressed as more terms, ie...
X = (x1, x2, x3)

A =
[ x1 + y1        y4       y7 ]
[      y2   x2 + y5       y8 ]
]      y3        y6  x3 + y9 ]

B =
[      y1   x2 + y4  x3 + y7 ]
[x1 +  y2        y5       y8 ]
]      y3        y6       y9 ]

b = [y1 y2 y3]'  (' means transposed)

Now we want to find the Jacobian of f - ie the partial derivative of f wrt X.

One way to do this is to multiply the two matrices and then multiply that by the vector, creating one 3x1 vector in which each element is an algebraic expression resulting from matrix multiplication.  The partial derivative could then be computed per element to form a 3x3 Jacobian.  This would be feasible in the above example, but the one I'm working is a lot more complicated (and so I would also have to look for patterns in order to simplify it afterwards).

I was wanting to try to use the chain rule and/or the product rule for partial derivatives if possible.  However, with the product rule you end up with A' * B * b + A * B' * b + A * B * b', where each derivative is wrt to the vector X.  I understand that the derivative of a matrix wrt a vector is actually a 3rd order tensor, which is not easy to deal with.  If this is not correct, the other terms still have to evaluate to matrices in order for matrix addition to be valid.  If I use the chain rule instead, I still end up with the derivative of a matrix wrt a vector.

Is there an easier way to break down a matrix calculus problem like this?  I've scoured the web and cannot seem to find a good direction.

### Quick question on parametric coordinates of triangle...

23 July 2013 - 04:28 PM

Suppose I have a 2D triangle.  It would have 3 vertices with 2D coordinates - (ua, va), (ub, vb), (uc, vc).

How could these be represented with parametric coordinates?

For example, if it was an equilateral triangle, what would the parametric coordinates be?

I've looked around for references but never find anything that can easily be applied to triangles.  Most people post guides on parametric equations and polar coordinates, which is a different topic.

### Issue with outputting rendered images to files after window is closed

12 June 2013 - 03:36 PM

I've been working on an OpenGL program and wanted to create a "video generation mode" where it outputs to a series of numbered targa files that can later be collated with a video editing tool.  I'm using glut with OpenGL (without shaders) and Visual C++ express on Windows.

What I've found is that it works fine when the window is open -- each output targa image is correct.

The moment I close the window, I found that the rendering code keeps running -- if I have cout's they keep printing to the console.  If does not render correctly to the targa images at that point - every other frame it is upside down and swaps red and blue.

If I could detect window close events, I could terminate the application on a window close so that it stops outputting targa images, but this version of glut does not have that callback and freeglut is not an option.

The relevant code is below...

//The following section is after the openGL rendering code

glReadBuffer(GL_BACK); //Tried with and without this line
glFlush();  //Tried with and without this line

//This does the buffer read

glReadPixels(0, 0, windowWidth, windowHeight, GL_RGBA, GL_UNSIGNED_BYTE, screenBuffer);

//Vertically flip the image in memory - it flips two rows from the screen in memory at a time

//The images will be upside down without this
for (int i = 0; i < windowHeight / 2; i++)
{
if (i != windowHeight - i)
{
memcpy(temp,(uint8_t *)&screenBuffer[i * windowWidth * 4], windowWidth * 4 * sizeof(uint8_t));
memcpy((uint8_t *)&screenBuffer[i * windowWidth * 4], (uint8_t *)&screenBuffer[(windowHeight - i) * windowWidth * 4], windowWidth * 4 * sizeof(uint8_t));
memcpy((uint8_t *)&screenBuffer[(windowHeight - i) * windowWidth * 4], temp, windowWidth * 4 * sizeof(uint8_t));

}
}

//I used the C targa library at -- http://dmr.ath.cx/gfx/targa/

sprintf(imageFileName, "videoFile%d.tga", frameNumber);
tga_result result = tga_write_rgb(imageFileName, screenBuffer, windowWidth, windowHeight, 32);

frameNumber++;

### Shape Context - Rotation Invariance

24 November 2012 - 06:54 PM

I was trying to implement Shape Context in order to identify a single textual character. I was trying to achieve rotation invariance.

The general approach for shape context is to compute distances and angles between each set of interest points in a given image. You then bin into a histogram based on whether these calculated values fall into certain ranges. You do this for both a standard and a test image. To match two different images, from this you use a chi-square function to estimate a "cost" between each possible pair of points in the two different histograms. Finally, you use an optimization technique such as the hungarian algorithm to find optimal assignments of points and then sum up the total cost, which will be lower for good matches.

I've checked several websites and papers, and they say that to make the above approach rotation invariant, you need to calculate each angle between each pair of points using the tangent vector as the x-axis. (ie http://www.cs.berkeley.edu/~malik/papers/BMP-shape.pdf page 513)

What exactly does this mean? No one seems to explain it clearly. Also, from which of each pair of points would you get the tangent vector - would you average the two?

A couple other people suggested I could use gradients (which are easy to find in toolsets such as Matlab) and use this as a substitute for the tangent points, though it does not seem to compute reasonable cost scores with this. Is it feasible to do this with gradients?

### Which of these is a better graduate school for graphics in computer science...

27 May 2012 - 11:21 PM

I've been applying to several schools for graduate work in computer science. My interests are graphics, physics simulations, interactive simulations, and artificial intelligence.
I currently work in Information Technology and could use a lot more training in my computer science areas of interest. These are two of the best looking offers I received.

Does anyone know if the University of Pennsylvania (UPenn) or Ohio State University is better if I decided I wanted to focus on the animation side of graphics programming (possibly interactive)?

It sounds like Ohio State has historically had a strong suit here, but I was concerned some of the animation professors may have left in recent years.
Ohio State does have a broader study in graphics, however.

UPenn (http://cg.cis.upenn.edu):
--Ivy League institution
--#17 in Computer Science
--3 professors that heavily focus on animation (or games). Also has a more expansive game development program.
--4 total graphics professors. It sounds like their graphics and game development programs are very well respected.
--They may have stronger AI - I saw 3 computer vision professors
--Admission to masters program. This Masters of Science of Engineering is NOT easily transferred to a PhD program at UPenn, but it is possible
--Financial support can be applied for but is limited for masters students. Tuition cost is \$55,000 for degree (probably 2 - 2.5 years).
--Industry connections look very good - Pixar, Dreamworks, Disney, Electronic Arts, Microsoft, Sony, Activision, Blue Sky Entertainment

Ohio State University (http://www.cse.ohio-state.edu/research/graphics/ and http://www.cse.ohio-state.edu/~parent/)
--Was noted for being a public institution with a rigor comparable to an Ivy League institution - a "public Ivy"
--#28 in Computer Science
--Only 1 professor that directly focuses research on animation. They do have more breadth in areas of graphics, however (animation, science, medical, computational geometry).
--7 total graphics professors. From what I'm hearing their graphics program is probably premiere.
--They don't have as dedicated of a "game development" program but they do have classes in it, and the courses teach the main topics one would need to know.
--The AI does look innovative - the computer vision project identifies suspicious behavior of thieves in parking lots. I know they also do sound analysis.
--Admission to PhD program. It is possible to downgrade to a masters if necessary by petitioning a committee.
--Full tuition waiver and stipend (with PhD program and Graduate Teaching Assistantship position). Without a waiver I think out of state tuition is \$26,000 / year, but it may be cheaper.
--I have seen very good industry connections - Graphics: Pixar, Dreamworks, EA Games, NVidia, National Labs. AI: BAE, Texas Instruments, Microsoft. Their graphics graduates historically have had a major impact on the film industry.

I also received offers for a masters program at Texas A&M (#47 in CS) and the University of Southern California (#20 in CS).
One of the main concerns now is the economy and jobs. If I did a masters degree, there is a chance I could perform my current job part time remotely while pursuing the masters degree.
As for the PhD it can be useful for becoming a researcher in some companies.

PARTNERS