Page 1 of 1

Possible to retrieve the full outline of an image?

Posted: 2010-06-22T00:41:15-07:00
by HikaruYami
Photoshop has a free downloadable plugin for this, but I need to have a program do this automatically followed by several more steps, the others of which I at least have a vague idea of how to do.

Image

Image

It should look something like that (what is generated in the example use of the aforementioned plugin; no, I do not need it to look that "pretty", and their tool usually doesn't do such a thing either, but I need it to catch notable depth and color changes all within the image, not merely the outer edges of a large body (though if it's a large, uniform object like a sphere, of course that's what it would do, lol).

Re: Possible to retrieve the full outline of an image?

Posted: 2010-06-22T02:30:09-07:00
by Bonzo

Re: Possible to retrieve the full outline of an image?

Posted: 2010-06-22T02:55:33-07:00
by HikaruYami
Oh god, thank you SO much, I must not have looked even a quarter as hard as I thought >.<

Really, thank you very much!!

Re: Possible to retrieve the full outline of an image?

Posted: 2010-06-22T21:19:26-07:00
by anthony
The above looks like it could use the new Convolving edge Detection kernel stuff.
http://www.imagemagick.org/Usage/convolve/#edgedet

Fred is however the better person to ask about it though -- fwm42?

Re: Possible to retrieve the full outline of an image?

Posted: 2010-06-22T21:38:47-07:00
by fmw42
Looks to me like a Canny type edge detection. But you can get close with a laplacian, for example

convert out_swap02.jpg \
-set option:convolve:scale '-1!' \
-morphology Convolve Laplacian:0 \
-colorspace gray -auto-level -threshold 5% -negate \
out_swap02_laplacian.jpg

Re: Possible to retrieve the full outline of an image?

Posted: 2010-06-22T23:17:09-07:00
by HikaruYami
Thanks for all the help~

But while I'm very interested in that last one, it seems to be giving me tons of junk pixels everywhere (medium-sized pseudo boxes all over the picture). Why is that?

Re: Possible to retrieve the full outline of an image?

Posted: 2010-06-23T09:59:01-07:00
by fmw42
HikaruYami wrote:Thanks for all the help~

But while I'm very interested in that last one, it seems to be giving me tons of junk pixels everywhere (medium-sized pseudo boxes all over the picture). Why is that?
What version of IM do you have? It may be older than the new -morphology function. If that is the case, you can still use -convolve "-1,-1,-1,-1,8,-1,-1,-1,-1". I am on IM 6.6.2-7 Q16 Mac OSX Tiger. When I run this, I get the following:

convert out_swap02.jpg \
-set option:convolve:scale '-1!' \
-morphology Convolve Laplacian:0 \
-colorspace gray -auto-level -threshold 5% -negate \
out_swap02_laplacian.jpg

Image

Be sure not to forget the % in the threshold.

If you are on windows. see about doubling %% at http://www.imagemagick.org/Usage/windows/

Re: Possible to retrieve the full outline of an image?

Posted: 2010-06-23T18:36:00-07:00
by HikaruYami
Oh, yeah, I didn't consider that it might require something different on windows. But I do have the most recent imagemagick version~

Is it also possibly relevant that I'm working with a drastically larger image?

Thanks again for all your help!

Re: Possible to retrieve the full outline of an image?

Posted: 2010-06-23T18:52:04-07:00
by fmw42
HikaruYami wrote:
Is it also possibly relevant that I'm working with a drastically larger image?

p!
Definitely!

try a larger threshold. But...

You might need a larger laplacian filter to avoid lots of small noise.

You might try either the LoG or Gradient Magnitude filters. See
http://www.imagemagick.org/Usage/convolve/#log

or last examples at
http://www.imagemagick.org/Usage/convolve/#sobel

Re: Possible to retrieve the full outline of an image?

Posted: 2010-06-23T18:56:39-07:00
by anthony
The fact that you are using a larger image could explain why your original sample look like it contains a lot of grey pixels. That is something you don't get which threshold is applied.

If you do have the latest IM you should also have the 'LOG' morphology kernals which generates a larger edge detection kernel that can 'delete' extraneous edges better. Sobel and other edge detector kernels could also be useful too. But you will then also have to use the -morphology convolve operator as the older operators have yet to be converted to the new method.

See http://www.imagemagick.org/Usage/convolve/ for more info. Fred can give more practical examples (yet to be added to IM examples).

I still have a speed issue (twice as slow) to resolve first and the older versions ability to use a GPU has to also merge into the morphology version. Once that is done then things can continue.

Note that a 'Canny' Edge detection was mentioned. This generates continuous lines in the image, but at the cost of disconnecting 'T' junctions. Unfortunately it has yet to be implemented, and may not be added for a long time yet, unless we get an interested programmer. It's so far down my own 'ToDo' list that it does not even appear, though I am interested in the operator.


Looks like Fred (fwm42) beat me to the submit with a similar answer and appropriate links to the exact same kernels I mentioned. :D

Re: Possible to retrieve the full outline of an image?

Posted: 2010-06-27T18:29:32-07:00
by HikaruYami
Thanks very much! Both of your replies helped a lot!