davbol wrote on Dec 17th, 2008, 1:30am:I don't know that code specifically, but the theory is correct - a matrix of all 1/9ths would be a blur filter (or a matrix of all 1's, then post-divided by 9). In implementing it though, make sure you specify 1f/9f (with the f's) to get a floating point result, instead of 1/9 which is an integer result (zero) -- which seems the likely cause of your black result. hth
Aha! Science praise you. That trick worked. The book doesn't put down 'f' next to each number in the example. I now have a working model that switches back and forth between sharp/blur on a mouse click.
Quick Question: Is that a casting issue
Edit: Correction, I
don't have a working model that changes from blur/sharp on a mouse click! What is the deal After the entire series of code, I added a new function that should change the convolution function's chief input:
(appended to the very bottom of the code)
Code:
void mousePressed() { //This sharpens.
float [][] matrix = { { -1, -1, -1},
{ -1, 9, -1},
{ -1, -1, -1} };
}
The program itself works but clicking the mouse doesn't do anything when it
should change into Sharpen mode. What gives?