Hi,in matlab for edge detection sobel,prewit,etc are
available,using edge command.There is also filter2,and
conv2 using fspecial command same sobel ,prewit are used.
Why and When I shpuld use
1)edge command and find edges.
2)filter2 or conv2 for same classical filter
(Sobel,Prewit...etc).
Plz explain the difference in detail because most of these
are used as edge detectors.
"Farwa Bat" <farwa@mathworks.com> wrote in message
<fm03vr$rjd$1@fred.mathworks.com>...
> Hi,in matlab for edge detection sobel,prewit,etc are
> available,using edge command.There is also filter2,and
> conv2 using fspecial command same sobel ,prewit are used.
> Why and When I shpuld use
>
> 1)edge command and find edges.
> 2)filter2 or conv2 for same classical filter
> (Sobel,Prewit...etc).
> Plz explain the difference in detail because most of these
> are used as edge detectors.
>
I believe the edge command returns a thresholded binary
image whereas the others just return the filtered image
without thresholding.
Thanks .... is this the only difference or there is some
more.
...................................................
"Peter Bone" <peterbone@hotmail.com> wrote in message
<fm047a$af4$1@fred.mathworks.com>...
> "Farwa Bat" <farwa@mathworks.com> wrote in message
> <fm03vr$rjd$1@fred.mathworks.com>...
> > Hi,in matlab for edge detection sobel,prewit,etc are
> > available,using edge command.There is also filter2,and
> > conv2 using fspecial command same sobel ,prewit are
used.
> > Why and When I shpuld use
> >
> > 1)edge command and find edges.
> > 2)filter2 or conv2 for same classical filter
> > (Sobel,Prewit...etc).
> > Plz explain the difference in detail because most of
these
> > are used as edge detectors.
> >
>
> I believe the edge command returns a thresholded binary
> image whereas the others just return the filtered image
> without thresholding.
The two are different in terms of method. Edge calculates the gradient
image and then applies a threshold to find where gradient is large--
the areas where intensity abruptly changes (edges). This is done in
spacial domain. Filt2 or conv2 convolves your image with a filter,
which is done in frequency domain. With fspecial you are defining the
filter, i.e. prewitt for edge sensitivity. Although the results may be
similar, the methods are different. The latter method is generally
more independent from intensity and dynamic range. Convolution is also
probably computationally less intensive.
On Jan 8, 3:10 pm, "Farwa Bat" <fa...@mathworks.com> wrote:
> Thanks .... is this the only difference or there is some
> more.
>
> ..................................................."Peter Bone" <peterb...@hotmail.com> wrote in message
>
> <fm047a$af...@fred.mathworks.com>...
>
> > "Farwa Bat" <fa...@mathworks.com> wrote in message
> > <fm03vr$rj...@fred.mathworks.com>...
> > > Hi,in matlab for edge detection sobel,prewit,etc are
> > > available,using edge command.There is also filter2,and
> > > conv2 using fspecial command same sobel ,prewit are
> used.
> > > Why and When I shpuld use
>
> > > 1)edge command and find edges.
> > > 2)filter2 or conv2 for same classical filter
> > > (Sobel,Prewit...etc).
> > > Plz explain the difference in detail because most of
> these
> > > are used as edge detectors.
>
> > I believe the edge command returns a thresholded binary
> > image whereas the others just return the filtered image
> > without thresholding.
The difference between the filter2 and conv2 are that in filter2, the filter mask in not flipped left right. you can get the same result when you call filter2 with its filter mask flipped left right. For example,
>> xf=filter2(x, fliplr(mask)); % filter2 as conv2
>> xc=conv2(x,mask);
Then xc and xf will be the same. Actually we do not need the filter2 and conv2 in MATLAB, since we can use filter2 as conv2 or conv2 as filter2 just by fliping the mask.
>> xc=conv2(x, fliplr(mask)); % conv2 as filter2
>> xf=filter2(x,mask);
here also, xc and xf will give the same result.
conv2 or filter2 is generalized function which can used for various filtering operation. Edge is a function specially designed for detecting edges in an image using only the known edge detection filters, such as prewitt, sobel, lapalcian of gausssian etc. One cannot use edge as a filtering operator with a different filter mask. Also, it return a binary image with black ground after removing the probable non edge regions and linking the probale edges in an image. In the case conv2 or filter2 the output is not a binary image. They are used as filtering operation in edge. After this, thresholding, thiniing and edge linking operations are applied to return binary image as ouput in edge.
Sorry, I have made a mistake in the explanation of filter2 and conv2. The two are equivalent under the following cases.
>>xf=filter2(fliplr(mask),x); % using as conv2
>>xc=conv2(x,mask, 'same');
then xc and xf are the same.
In the other way,
>>xc=conv2(x,fliplr(mask), 'same'); % using as filter2
>>xf=filter2(mask,x);
here also, xc and xf will give the same result.
I still don't get the same result Yumnam. I am using Matlab
release 7.5.0(R2007b), it should be a strange thing but
maybe there's where the error is? I've posted a picture at http://www.student.tue.nl/t/r.j.m.janssen/FILTERS.jpg
The kernel (or mask) is defined as [0 -1; 1 0]
Can you maybe take a look at it and explain why there's
still a difference?
Regards,
Robbie
Yumnam Kirani Singh <kirani.singh@gmail.com> wrote in
message
<30971887.1199861291430.JavaMail.jakarta@nitrogen.mathforum.
org>...
> Sorry, I have made a mistake in the explanation of
filter2 and conv2. The two are equivalent under the
following cases.
> >>xf=filter2(fliplr(mask),x); % using as conv2
> >>xc=conv2(x,mask, 'same');
> then xc and xf are the same.
> In the other way,
> >>xc=conv2(x,fliplr(mask), 'same'); % using as filter2
> >>xf=filter2(mask,x);
> here also, xc and xf will give the same result.
Got it, you should (at least not in my Matlab version)
transpose the mask instead of just flipping it from left to
right. See matlab-help for filter2
"Robbie Janssen" <r.j.m.janssen@student.tue.nl> wrote in
message <fvp9cr$1ca$1@fred.mathworks.com>...
> I still don't get the same result Yumnam. I am using
Matlab
> release 7.5.0(R2007b), it should be a strange thing but
> maybe there's where the error is? I've posted a picture
at
> http://www.student.tue.nl/t/r.j.m.janssen/FILTERS.jpg
>
> The kernel (or mask) is defined as [0 -1; 1 0]
>
> Can you maybe take a look at it and explain why there's
> still a difference?
>
> Regards,
>
> Robbie
>
> Yumnam Kirani Singh <kirani.singh@gmail.com> wrote in
> message
>
<30971887.1199861291430.JavaMail.jakarta@nitrogen.mathforum.
> org>...
> > Sorry, I have made a mistake in the explanation of
> filter2 and conv2. The two are equivalent under the
> following cases.
> > >>xf=filter2(fliplr(mask),x); % using as conv2
> > >>xc=conv2(x,mask, 'same');
> > then xc and xf are the same.
> > In the other way,
> > >>xc=conv2(x,fliplr(mask), 'same'); % using as filter2
> > >>xf=filter2(mask,x);
> > here also, xc and xf will give the same result.
>
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.