Discussion Board

Results 1 to 6 of 6

Threaded View

  1. #1
    Registered User
    Join Date
    Oct 2006

    Image processing - Sobel filter problem (edge detection)

    Hi everyone,

    I'm trying to perform edge detection on a bitmap I get from the camera viewfinder, using a simple sobel operator. It's quite a straight forward task, but somehow the result doesn't look like expected (something like this for the x/y gradients: http://www.dca.fee.unicamp.br/dipcou...-sobel-x-y.gif )

    This is my code (both bitmaps are EGray256):
    	TInt8* gImg = (TInt8*)iGrayBitmap->DataAddress();
    	TInt8* proImg = (TInt8*)iProcessedBitmap->DataAddress();
    	TInt x=0, y=0, i=0, dx=0, dy=0;		
    	for(i=0; i<w*h; i++) 
    		// if we're at the first column - first pixel of a row:
    		// increment rows x and reset columns y
    		if (i==(y+1)*w) { y++; x=0; }
                    // else increment columns
    		else { x++; }
    		// if we're not in the first column or the first/last row (image boundaries)
    		// apply Sobel filter
    		if(x!=0 && x!=w-2 && y!=0 && y!=h-2 )
    			dx = gImg[i-w-1] + gImg[i-w+1] + gImg[i-w]*2 - gImg[i+w-1] - gImg[i+w+1] - 2*gImg[i+w];
    			dy = gImg[i-w-1] + gImg[i+w-1] + gImg[i-1]*2 - gImg[i-w+1] - gImg[i-w+1] - 2*gImg[i+1];
                            proImg[i] = dx;
    			proImg[i] = 255;
    As you can see here, the edges are detected, but where does all the white noise come from? Shouldn't it be just plain gray? (the test image is a white triangle on a light gray background, the screenshot is from the horizontal gradient)
    Original image:

    Does anybody see what might be the problem?

    Last edited by sbail; 2009-07-25 at 16:39.

Similar Threads

  1. Problem regarding creating ROM image
    By eternity007 in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2009-05-21, 09:37
  2. image uploading problem
    By vkrnt18 in forum General Development Questions
    Replies: 3
    Last Post: 2007-06-22, 14:01
  3. image processing problem
    By alexboy in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2006-11-08, 05:36
  4. how to cut some part of Image
    By mshouab in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2006-08-04, 09:05
  5. Replies: 1
    Last Post: 2003-04-19, 22:28

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts