writing my own sobel filter convolution - something is wrong


Posted on 16th Feb 2014 07:03 pm by admin

I am trying to keep it very simple, I cant see anything wrong with my logic, could anybody help point me to the right direction?!!


Code: { int Shorizontal[] = {-1, 0, 1, -2, 0, 2, -1, 0, 1}; int Svertical[] = {1, 2, 1, 0, 0, 0, -1, -2, -1}; for (int x = 0; x < image.dimx(); x++) for (int y = 0; y < image.dimy(); y++) for (int c = 0; c < 3; c++) // loop through colour channels { int counter = 0; float tempH = 0; float tempV = 0; for (int a = -1; a <= 1; a++) for (int b = -1; b <= 1; b++) if (x + a >= 0 && x + a <= image.dimx() && y + b >= 0 && y + b <= image.dimy()) { tempH += image(x + a,y + b,0, c) * Shorizontal[counter]; tempV += image(x + a,y + b,0, c) * Svertical[counter]; counter++; } image(x,y,0,c) = sqrt(pow(tempH,2) + pow(tempV,2)); } }

No comments posted yet

Your Answer:

Login to answer
291 Like 22 Dislike
Previous forums Next forums
Other forums

Unidentified index error in a simple form
I have been trying to make an HTML form that is handled by a PHP script. So far my attempts to get i

Javascript or not?
How many people prefer javascript/ajax sites? How many prefer the good old fashion straight php sit

Delete all files in folder except with certain name
I have a script that I want to delete all files in a folder (taken from a database) except for one n

Embedding flash object in Else statement
This is my first major project in PHP and I'm having some trouble embedding a flash object in an Els

Array question
Does anyone know how to create a program that takes the $ amount for 8 different departments and gi

Executing an exe
Hi. I have some bizarre problem with exec (other any other method) to launch exe's. I am making a ga

urldecode question
How would I format this line of code properly?

<?php echo urldecode($_GET['Title']); ?

database design
Hi,

I got a page which allow candidate to type in their previous working experience,
I let

OOP help
okay so i have a class im making it has everything setup i just need to randomize the 2 variables an

question about n
I was looking at some of the things you could do with php and one of the things I have tried is n.<

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash