[vtkusers] image island removal and hole filling

Jonathan Morra jonmorra at gmail.com
Mon Dec 6 16:29:41 EST 2010


Thanks, the first suggestion worked exactly like I expected and the speed is
totally fine.

Thanks again.

On Mon, Dec 6, 2010 at 1:26 PM, David Gobbi <david.gobbi at gmail.com> wrote:

> Hi Jonathan,
>
> In your original email you said that you need to select one island in your
> image (i.e. to keep only that island), and then fill the holes in that
> island.  When I said "island removal" in my last email, I actually just
> meant fill the holes.  I didn't mean to refer to the other islands.
>
> If your data is 0 and 1, then you should be able to select white with:
>
> ThresholdBetween(1,1) // only fill pixels that have a value of 1
> SetOutValue(0) // set all other pixels black
>
> ThresholdBetween(0,0) // only fill pixels that have a value of 0
> SetOutValue(1) // set all other pixels white
>
>   David
>
>
> On Mon, Dec 6, 2010 at 2:09 PM, Jonathan Morra <jonmorra at gmail.com> wrote:
>
>> My data is all either 0 or 1.  I'm not sure why I have to know seed points
>> in the other islands.  I don't know if I'm going to be able to get those
>> points.  Basically I want to keep the one island that has the mouse on it,
>> that's how I know the one point I'm interested in.
>>
>>
>> On Mon, Dec 6, 2010 at 12:11 PM, David Gobbi <david.gobbi at gmail.com>wrote:
>>
>>> Hi Jonathan,
>>>
>>> If you are setting the FloodExtent to a size that is larger than the
>>> region that will be selected by the fill, then it shouldn't have any effect.
>>>  As it says in the documentation, SetFloodExtent() is meant to restrict the
>>> flood fill to e.g. one slice of a 3D volume.
>>>
>>> This filter will not automatically remove islands, it just floods each
>>> connected region that contains a seed.  For island removal, you would have
>>> to invert the threshold and then put a seed inside every island that you
>>> want to remove.
>>>
>>> I suspect that the thresholds are not set correctly.  What is the data
>>> range of your image?  Is it [0,1]?  Or [0,255]?
>>>
>>>   David
>>>
>>>
>>> On Mon, Dec 6, 2010 at 12:38 PM, Jonathan Morra <jonmorra at gmail.com>wrote:
>>>
>>>> While, I'd love to use ITK, I haven't had luck getting ITK, VTK, and
>>>> Java to play together, so I'd like to stick with VTK for now.
>>>>
>>>> David -- I'm still having issues with the filter.
>>>>  1.  The filter has to run in real time because this is called on a
>>>> mouse move event.  However, I know a bounding box outside of which all
>>>> voxels are guaranteed to have a value of 0.  Therefore I went ahead and used
>>>> the SetFloodExtent method and set it to my known bounding box, is this OK?
>>>> 2  I'm still seeing islands in the resulting binary mask, here is the
>>>> latest version of what I'm doing, any ideas?
>>>>
>>>>             vtkPoints seedPoints = new vtkPoints();
>>>>
>>>>  seedPoints.InsertNextPoint(panel.getPicker().GetPickPosition());
>>>>             vtkImageFloodFill fill = new vtkImageFloodFill();
>>>>             fill.SetInput(binaryImage);
>>>>             fill.SetSeedPoints(seedPoints);
>>>>             fill.ThresholdByLower(1);
>>>>             fill.SetFloodExtent(bounds);
>>>>             fill.Update();
>>>>             binaryImage = fill.GetOutput();
>>>>
>>>> On Mon, Dec 6, 2010 at 10:34 AM, Karthik Krishnan <
>>>> karthik.krishnan at kitware.com> wrote:
>>>>
>>>>> Or you could process the pipeline in ITK, if you are willing to
>>>>> incorporate another toolkit..
>>>>>
>>>>> itk::ConnectedThresholdImageFilter ->
>>>>> VotingBinaryHoleFillingImageFilter (or its iterative version)
>>>>>
>>>>>
>>>>> On Mon, Dec 6, 2010 at 11:49 PM, David Gobbi <david.gobbi at gmail.com>
>>>>> wrote:
>>>>> > I think I made a mistake... I should have told you to use
>>>>> > ThresholdByLower(1).  Other than that, your code looks fine.
>>>>> >   David
>>>>> >
>>>>> > On Mon, Dec 6, 2010 at 11:13 AM, Jonathan Morra <jonmorra at gmail.com>
>>>>> wrote:
>>>>> >>
>>>>> >> I just got your class in my version of vtk and up and running in
>>>>> Java, and
>>>>> >> it's not working for me.  I was wondering what I'm doing wrong,
>>>>> could you
>>>>> >> help me out?
>>>>> >> Thanks
>>>>> >>             // We have to remove all the islands not connected to
>>>>> the
>>>>> >> center
>>>>> >>             // and then fill the holes in the resulting mask
>>>>> >>             vtkPoints seedPoints = new vtkPoints();
>>>>> >>
>>>>> >>  seedPoints.InsertNextPoint(panel.getPicker().GetPickPosition());
>>>>> >>             vtkImageFloodFill fill = new vtkImageFloodFill();
>>>>> >>             fill.SetInput(binaryImage);
>>>>> >>             fill.SetSeedPoints(seedPoints);
>>>>> >>             fill.ThresholdByUpper(1);
>>>>> >>             fill.Update();
>>>>> >>             binaryImage = fill.GetOutput();
>>>>> >> On Fri, Dec 3, 2010 at 11:27 AM, Jonathan Morra <jonmorra at gmail.com
>>>>> >
>>>>> >> wrote:
>>>>> >>>
>>>>> >>> Fantastic, thanks for your help!
>>>>> >>>
>>>>> >>> On Fri, Dec 3, 2010 at 11:13 AM, David Gobbi <
>>>>> david.gobbi at gmail.com>
>>>>> >>> wrote:
>>>>> >>>>
>>>>> >>>> Hi Jonathan,
>>>>> >>>> I put my flood-fill filter on github, and tested it to make sure
>>>>> it
>>>>> >>>> still works:
>>>>> >>>> http://github.com/dgobbi/VTK/tree/flood-fill/Imaging/
>>>>> >>>>
>>>>> >>>> The interface is just like the vtkThresholdFilter, except that it
>>>>> >>>> has a method called SetSeedPoints() to allow you to set your
>>>>> >>>> seeds.  For a binary image, call ThresholdByUpper(1) so that
>>>>> >>>> you can set seeds inside any non-zero islands that you want
>>>>> >>>> to keep in your output.
>>>>> >>>> I'll probably contribute this class to VTK after I have brought
>>>>> >>>> it up-to-date (it was originally written for VTK 4).
>>>>> >>>>   David
>>>>> >>>>
>>>>> >>>> On Thu, Dec 2, 2010 at 3:39 PM, Jonathan Morra <
>>>>> jonmorra at gmail.com>
>>>>> >>>> wrote:
>>>>> >>>>>
>>>>> >>>>> Thanks, let me know where I can download it from.
>>>>> >>>>>
>>>>> >>>>> On Thu, Dec 2, 2010 at 2:36 PM, David Gobbi <
>>>>> david.gobbi at gmail.com>
>>>>> >>>>> wrote:
>>>>> >>>>>>
>>>>> >>>>>> For Step 1, I have a VTK flood-fill class that do the job.  I'll
>>>>> >>>>>> upload it to
>>>>> >>>>>> gerrit so that you can try it out.  I don't think anything
>>>>> exists for
>>>>> >>>>>> your
>>>>> >>>>>> Step 2, though.
>>>>> >>>>>>   David
>>>>> >>>>>>
>>>>> >>>>>> On Thu, Dec 2, 2010 at 3:14 PM, Jonathan Morra <
>>>>> jonmorra at gmail.com>
>>>>> >>>>>> wrote:
>>>>> >>>>>>>
>>>>> >>>>>>> I have a binary vtkImageData class and I want to do 2 things
>>>>> with it,
>>>>> >>>>>>> and I don't know how.
>>>>> >>>>>>> 1.  I want to remove all islands from the image except one.  I
>>>>> want
>>>>> >>>>>>> to identify the island not to be removed by a pixel location.
>>>>>  I have seen
>>>>> >>>>>>> vtkImageIslandRemoval2D, and I don't think that'll work for me,
>>>>> because I do
>>>>> >>>>>>> not know anything about the island's size that I want to keep
>>>>> (it could be
>>>>> >>>>>>> big, small, or in the middle), all that I know is one point
>>>>> which
>>>>> >>>>>>> is guaranteed to be interior to one island, and that's the
>>>>> island I want to
>>>>> >>>>>>> keep.
>>>>> >>>>>>> 2.  I want to do hole filling on the output of step 1 and I
>>>>> don't
>>>>> >>>>>>> know how to do that.  I saw vtkFillHolesFilter but that appears
>>>>> only to work
>>>>> >>>>>>> on poly data.  I'd like something analogous to that for
>>>>> vtkImageData.
>>>>> >>>>>>> If anyone knows how to do these things, I'd appreciate it.
>>>>>  Also, if
>>>>> >>>>>>> it matters, I'm coding in Java.
>>>>> >>>>>>> Thanks
>>>>> >>>>>>> _______________________________________________
>>>>> >>>>>>> Powered by www.kitware.com
>>>>> >>>>>>>
>>>>> >>>>>>> Visit other Kitware open-source projects at
>>>>> >>>>>>> http://www.kitware.com/opensource/opensource.html
>>>>> >>>>>>>
>>>>> >>>>>>> Please keep messages on-topic and check the VTK FAQ at:
>>>>> >>>>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>>> >>>>>>>
>>>>> >>>>>>> Follow this link to subscribe/unsubscribe:
>>>>> >>>>>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>>> >>>>>>>
>>>>> >>>>>>
>>>>> >>>>>
>>>>> >>>>
>>>>> >>>
>>>>> >>
>>>>> >
>>>>> >
>>>>> > _______________________________________________
>>>>> > Powered by www.kitware.com
>>>>> >
>>>>> > Visit other Kitware open-source projects at
>>>>> > http://www.kitware.com/opensource/opensource.html
>>>>> >
>>>>> > Please keep messages on-topic and check the VTK FAQ at:
>>>>> > http://www.vtk.org/Wiki/VTK_FAQ
>>>>> >
>>>>> > Follow this link to subscribe/unsubscribe:
>>>>> > http://www.vtk.org/mailman/listinfo/vtkusers
>>>>> >
>>>>> >
>>>>>
>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101206/2c269832/attachment.htm>


More information about the vtkusers mailing list