13
$\begingroup$

I want to extract subimages from an image like below. There are 6 components in the image, I want to crop this image into 6 images in a way each individual image contain only 1 component. Can I automatically do it by Mathematica?

enter image description here

Thanks in advance.

$\endgroup$
5
  • 4
    $\begingroup$ ImagePartition[ ] or MorphologicalComponents[ ]? $\endgroup$ Commented Mar 5, 2016 at 8:03
  • $\begingroup$ Welcome! Can you please elaborate? At the moment it is not clear what exactly you want to achieve. $\endgroup$ Commented Mar 5, 2016 at 8:11
  • 1
    $\begingroup$ Look up ComponentMeasurements and ImageTrim in the documentation. $\endgroup$ Commented Mar 5, 2016 at 8:59
  • 1
    $\begingroup$ @HayashiYoshiaki Look at this question $\endgroup$ Commented Mar 5, 2016 at 9:00
  • $\begingroup$ There are 6 components in the image, I want to crop this image into 6 images in a way each individual image contain only 1 component. $\endgroup$ Commented Mar 5, 2016 at 9:01

1 Answer 1

16
$\begingroup$

Thanks martin !!

SplitImage[image_] := Module[ {m, components}, m = MorphologicalComponents[image]; components = ComponentMeasurements[{m, image}, {"Area", "BoundingBox"},#1>100&]; ImageTrim[image, #] & /@ components[[All, 2, 2]] ] 

enter image description here

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.