Re: How to cut an image into image parts ?

Posted by Michael Schmid on
URL: http://imagej.273.s1.nabble.com/How-to-cut-an-image-into-image-parts-tp3682979p3682985.html

Hi rajava,

You need two things:
(1) the image with the background not appearing as an object.
(2) a Wand that can omit interior holes. You can use the Versatile  
Wand from
   http://imagejdocu.tudor.lu/doku.php?
id=plugin:segmentation:versatile_wand:start

Assuming pixel (0,0) is background:

run("RGB Color");
run("8-bit");
setAutoThreshold("Default dark");
run("Apply LUT");
run("Versatile Wand", "value=0 color=0 gradient=0 connectedness=8-
connected x=0 y=0 do");
run("Clear", "slice"); //surrounding should be background
run("Select None");
run("Find Maxima...", "noise=0 output=List light");

Then have a loop and run the wand with the x and y coordinates of  
each line in the Results Table, Duplicate and 'Clear Outside' in the  
new image; then select the original again for selecting the next part.

Note that "Find Maxima..." always reports the position of a  
foreground pixel of the object, it will never give you the position  
of an inner hole or even a pixel.
An alternative would be "Analyze Particles" with "Record Starts" on,  
then use the XStart and YStart for the wand.


Michael
________________________________________________________________

On 26 Sep 2011, at 13:34, rajava wrote:

> I am trying to write a macro to cut a simple line drawing image  
> into image
> parts. I am trying to use the wand tool and cut but it doesn't seem  
> to work.
> The is the sample image
> Here is the code i was trying ,
> open("http://www.coloringparty.eu/images/zoom/toddlers/viewsize/ 
> Rocket-toddlers.gif")
> doWand(177, 478);
> run("Cut");
> doWand(338,321);
> run("Cut");
> Also, Is there a way to find a point(x,y) to doWand so that it  
> comprises of
> a part and find as much part as possible programmatically ? Any  
> help is this
> matter is greatly appreciated, Thanks.
> http://imagej.588099.n2.nabble.com/file/n6831553/Rocket-toddlers.gif
>
> Cut image should something like this , but this was cut using wand  
> manually,
> http://imagej.588099.n2.nabble.com/file/n6831553/imageparts.png
>
> --
> View this message in context: http://imagej.588099.n2.nabble.com/ 
> How-to-cut-an-image-into-image-parts-tp6831553p6831553.html
> Sent from the ImageJ mailing list archive at Nabble.com.