DSPRelated.com
Forums

about edge detection

Started by Snehal September 21, 2002
Hi
I am just learning image processing.
I want to implement edge detection by sobel operator in 'c', i am
facing some problems. i am first reading image. then i am applying
first mask to it and gradient(let gx) in another veriable. now i am
applying second mask to original image and saving that gradient(let
gy).
now my final value of gradient is g=|gx|+|gy| (as per approximate eq)

my que are
1. what should we do if value of g is greater than max gray level (in
my case it is 255)?
2. value of gx or gy may be -ve so is it required to do some scaling
to it before adding?
3. is we have to divide by some factor (like 9 in 3x3 low pass filter
where all mask elements have value 1) while applying mask?
4. does sobel or prewitt operator have some limitations regarding
type of image? can i use these operators to find edge of human face
(eg std. image of lena)

i am facing some prob. i have implemented sobel operator. i download
some images from net and use them to find edge detection but the
resultant image have blurring effect where as on net i found highly
enhanced image for same image

so i am not getting where i am wrong........

so plz help me if u can.......
thank in advance

Snehal




gradient magnitude is given by
|G| = (Gx^2 + Gy^2)^1/2

Although typically, an approximate magnitude is computed using:
|G| = |Gx| + |Gy|
It is faster to compute.

Output values from the operator can easily overflow the maximum allowed
pixel value for image types that only support smallish integer pixel values
(e.g. 8-bit integer images). When this happens the standard practice is to
simply set overflowing output pixels to the maximum allowed value. The
problem can be avoided by using an image type that supports pixel values
with a larger range.

i.e You can make magnitudes >255 = 255. Good Luck,
Sayaji

>From: "Snehal" <>
>To:
>Subject: [imagedsp] about edge detection
>Date: Sat, 21 Sep 2002 11:32:07 -0000
>MIME-Version: 1.0
>X-Originating-IP: 203.200.42.210
>Received: from n15.grp.scd.yahoo.com ([66.218.66.70]) by
>mc4-f34.law16.hotmail.com with Microsoft SMTPSVC(5.0.2195.5600); Mon, 23
>Sep 2002 06:41:40 -0700
>Received: from [66.218.67.192] by n15.grp.scd.yahoo.com with NNFMP; 23 Sep
>2002 13:42:01 -0000
>Received: (qmail 42832 invoked from network); 23 Sep 2002 13:41:58 -0000
>Received: from unknown (66.218.66.216) by m10.grp.scd.yahoo.com with QMQP;
>23 Sep 2002 13:41:58 -0000
>Received: from unknown (HELO n28.grp.scd.yahoo.com) (66.218.66.84) by
>mta1.grp.scd.yahoo.com with SMTP; 23 Sep 2002 13:41:58 -0000
>Received: from [66.218.67.154] by n28.grp.scd.yahoo.com with NNFMP; 23 Sep
>2002 13:41:58 -0000
>Received: (EGP: mail-8_1_1_3); 21 Sep 2002 11:32:08 -0000
>Received: (qmail 2898 invoked from network); 21 Sep 2002 11:32:08 -0000
>Received: from unknown (66.218.66.218) by m7.grp.scd.yahoo.com with QMQP;
>21 Sep 2002 11:32:08 -0000
>Received: from unknown (HELO n9.grp.scd.yahoo.com) (66.218.66.93) by
>mta3.grp.scd.yahoo.com with SMTP; 21 Sep 2002 11:32:08 -0000
>Received: from [66.218.67.174] by n9.grp.scd.yahoo.com with NNFMP; 21 Sep
>2002 11:32:08 -0000
>X-eGroups-Return:
>
>X-eGroups-Return:
>X-Sender:
>X-Apparently-To:
>Message-ID: <>
>User-Agent: eGroups-EW/0.82
>X-Mailer: Yahoo Groups Message Poster
>X-Yahoo-Profile: snehal_joshi007
>X-eGroups-Approved-By: s_boucheryah <> via web; 23
>Sep 2002 13:41:56 -0000
>Mailing-List: list ; contact
>
>Delivered-To: mailing list
>Precedence: bulk
>List-Unsubscribe: <mailto:>
>Return-Path:
>
>X-OriginalArrivalTime: 23 Sep 2002 13:41:40.0125 (UTC)
>FILETIME=[F20654D0:01C26306]
>
>Hi
>I am just learning image processing.
>I want to implement edge detection by sobel operator in 'c', i am
>facing some problems. i am first reading image. then i am applying
>first mask to it and gradient(let gx) in another veriable. now i am
>applying second mask to original image and saving that gradient(let
>gy).
>now my final value of gradient is g=|gx|+|gy| (as per approximate eq)
>
>my que are
>1. what should we do if value of g is greater than max gray level (in
>my case it is 255)?
>2. value of gx or gy may be -ve so is it required to do some scaling
>to it before adding?
>3. is we have to divide by some factor (like 9 in 3x3 low pass filter
>where all mask elements have value 1) while applying mask?
>4. does sobel or prewitt operator have some limitations regarding
>type of image? can i use these operators to find edge of human face
>(eg std. image of lena)
>
>i am facing some prob. i have implemented sobel operator. i download
>some images from net and use them to find edge detection but the
>resultant image have blurring effect where as on net i found highly
>enhanced image for same image
>
>so i am not getting where i am wrong........
>
>so plz help me if u can.......
>thank in advance
>
>Snehal >

_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx


Hi,
> I am just learning image processing.
> I want to implement edge detection by sobel operator in 'c', i am
> facing some problems. i am first reading image. then i am applying
> first mask to it and gradient(let gx) in another veriable. now i am
> applying second mask to original image and saving that gradient(let
> gy).
> now my final value of gradient is g=|gx|+|gy| (as per approximate eq)
>
> my que are
> 1. what should we do if value of g is greater than max gray level (in
> my case it is 255)?

Well to the best of my knolwedge, when you are applying an operator on an
image whose values range between 0 and 255, the result will never exceed 255
or the maximum value that an image can take. In case it doing so either you
are not balancing the coefficients properly (which I think is the case) else
u need to threshold the result ( which I dont think can happen) > 2. value of gx or gy may be -ve so is it required to do some scaling
> to it before adding?

Same as above.

> 3. is we have to divide by some factor (like 9 in 3x3 low pass filter
> where all mask elements have value 1) while applying mask?

see when u apply a median filter in spatial domain, the sum of the
coefficients will be 1, whereas for Sobel and Prewitt operators, the sum of
coefficients in the mask will be 0 (Ref. Pg. 349 Sec.9.4. Fundamental of
Digital Image Processing by A K Jain)

> 4. does sobel or prewitt operator have some limitations regarding
> type of image? can i use these operators to find edge of human face
> (eg std. image of lena)

See the edge detection operators have the property that they yield zeroes
for uniform regions.
Also I am not too sure how you are finding the edge map... Are u
thresholding after you add the gradients.basically you should get a binary
image where a pixel can either be 0 or 255. > i am facing some prob. i have implemented sobel operator. i download
> some images from net and use them to find edge detection but the
> resultant image have blurring effect where as on net i found highly
> enhanced image for same image
>
> so i am not getting where i am wrong........
Hope my answers help you but I suggest you try some morphological gradients
for good edge detection.
Do revert in case you require anymore help.
Ganesh ***********************************
Ganesh Vijayan
DSP Desgin Engineer - Video
Emuzed India (P) Ltd.
Bangalore
www.emuzed.com
*************************************


>Hi,
>> I am just learning image processing.
>> I want to implement edge detection by sobel operator in 'c', i am
>> facing some problems. i am first reading image. then i am applying
>> first mask to it and gradient(let gx) in another veriable. now i am
>> applying second mask to original image and saving that gradient(let
>> gy).
>> now my final value of gradient is g=|gx|+|gy| (as per approximate eq)
>>
>> my que are
>> 1. what should we do if value of g is greater than max gray level (in
>> my case it is 255)?
>
>Well to the best of my knolwedge, when you are applying an operator on an
>image whose values range between 0 and 255, the result will never exceed 255
>or the maximum value that an image can take. In case it doing so either you
>are not balancing the coefficients properly (which I think is the case) else
>u need to threshold the result ( which I dont think can happen)
>

How about convolving [0 0 0 0 255 0 0 0 0] with [-1 2 -1] ?

>
>> 2. value of gx or gy may be -ve so is it required to do some scaling
>> to it before adding?
>
>Same as above.
>

-ve signifies an 'opposite' edge (ie dark to lighht vs light to dark.

<snip>
>> i am facing some prob. i have implemented sobel operator. i download
>> some images from net and use them to find edge detection but the
>> resultant image have blurring effect where as on net i found highly
>> enhanced image for same image
>>
>> so i am not getting where i am wrong........

Post some of your outputs so we can have a look. Also, if you have Paintshop
PRo you can do a Sobel (eg) in that for comparison purposes.

Cheers,
Martin

--
Martin Thompson BEng(Hons) CEng MIEE
TRW Conekt
Stratford Road, Solihull, B90 4GW. UK
Tel: +44 (0)121-627-3569 -



Martin-

> >Well to the best of my knolwedge, when you are applying an operator on an
> >image whose values range between 0 and 255, the result will never exceed 255
> >or the maximum value that an image can take. In case it doing so either you
> >are not balancing the coefficients properly (which I think is the case) else
> >u need to threshold the result ( which I dont think can happen)
> >
>
> How about convolving [0 0 0 0 255 0 0 0 0] with [-1 2 -1] ?

Thanks for the morning laugh. Not to mention that practical DSP/fixed-point
implementations are filled with fun issues like overflow, saturation, guard
bands,
etc.

Jeff Brower
DSP sw/hw engineer
Signalogic