How to use sobel's edge detect in both direction (urgent)

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
cherry

How to use sobel's edge detect in both direction (urgent)

Post by cherry »

I would like to extract feature. How to use sobel's edge detection algorithm in both direction horizontal and vertical in command line. I use -convolve -1,0,1,-2,0,2,-1,0,1 function but it's seem cannot detect edge properly.

Please suggest me in urgent .
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to use sobel's edge detect in both direction (urgent

Post by fmw42 »

if you are not using HDRI IM, then you need to add -bias and then -solarize and -level. see viewtopic.php?f=1&t=14491&hilit=sobel#p50361

also see http://www.imagemagick.org/Usage/morpho ... olve_other

Original:
Image

DX:
convert zelda3.jpg -bias 50% -convolve "-1,0,1,-2,0,2,-1,0,1" -solarize 50% -level 50,0% zelda3_dx.jpg
Image

DY:
convert zelda3.jpg -bias 50% -convolve "-1,-2,-1,0,0,0,1,2,1" -solarize 50% -level 50,0% zelda3_dy.jpg
Image


Gradient:
convert zelda3.jpg \
\( -clone 0 -bias 50% -convolve "-1,0,1,-2,0,2,-1,0,1" \
-solarize 50% -level 50,0% \) \
\( -clone 0 -bias 50% -convolve "-1,-2,-1,0,0,0,1,2,1" \
-solarize 50% -level 50,0% \) \
-delete 0 -compose plus -composite zelda3_grad.jpg
Image


see also my gradient script (with option -v 2)
Post Reply