[Insight-users] ConnectedComponents and
RelabeledConnectedComponents
Zachary Pincus
zpincus at stanford.edu
Sat Jan 8 14:17:30 EST 2005
Hi Ken,
I wind up using these filters quite a bit, so let's see if we can get
to the bottom of your trouble...
(1) Could you post the code and sample files you're using that don't
work? Also, what version of ITK are you using?
(2) Probably the best image type to use is unsigned short, to get
unsigned 16-bit image values. 16-bit TIFFs work fine with any
"scientific" type viewer. Try imageJ, for example. 16 bits should be
enough for the number of objects in your image?
(3) To best isolate the problem, I'd try to JUST run the
ConnectedComponents filter first to verify that it's working. Run the
filter, save a TIFF, and open it in imageJ (or whatever) and look at
the histogram. It should be spiky, like there are big blocks of pixels
with the same label. Also look at the image to determine whether each
connected component has the same label. (You might of course have to
adjust the contrast). If that filter seems to work, we can focus our
attentions on the relabel filter.
(4) If all you really want to do is *count* the connected components,
in the long run the best option is probably to modify the
ConnectedComponentsImageFilter to report the count of objects (a
trivial modification -- I can help with that if you want), to avoid
having to run the relabel filter just to count the objects. But we
should solve the original problem first...
Zach Pincus
Department of Biochemistry and Program in Biomedical Informatics
Stanford University School of Medicine
On Jan 7, 2005, at 10:34 AM, Ken Urish wrote:
> Im a long times listener, first time caller -
>
> Ive hit a brick wall that I have not been able to get past for the
> past week and a half using ConnectedComponentsImageFilter and
> RelabeledComponentsImageFilter.
>
> I have a binary tiff (unisgned char) image that I have thresholded,
> and I want to count the number of white pixeled islands against a
> black background. I am using ConnectedComponentsImageFilter and then
> I use RelabeledComponents to count the number of islands. The program
> works if I have only 5 or less white connected components( CC ). It
> falls apart if I have a large number of CCs. Ultimately I will have
> more than a thousand.
>
> Fooling around with different pictures, here is my problem:
> 1) No matter how many CCs I have, I always generate the itk warning:
> "ConnectedComponentImageFilter::GenerateData: Number of labels exceeds
> number of available labels for the output type." If I have only 5 or
> 7 CCs, even thou the warning is generated I still get an accurate
> answer, however I think this is the root of my problem.
> 2) If I take the same picture I made that has 5 white pixeled islands,
> copy it over and over to use as a template to make images of 10, 25,
> 50 and 75 white pixeled CCs, and print out the size of the connected
> components, I will only get a max of 5 connected components even when
> I have 75 CC. In addition, at 25, 50 and 75 CCs all of the CCs that
> are counted all have the same size and are all the very 1st white
> island I have of the series of 5 pixeled island.
>
> - I thought that I could fix the problem using "unsigned long" or
> "unsigned int". If I do this I get the CC saying I have only 0 and of
> course I cant view the image since its not supported by tiff or jpeg.
>
> -Even if i get an accurate count of 75 or 100 white pixeled islands
> how can I get it too handle 500, 1000, or even 10,000??? I am
> absolutely baffeled, please help.
>
> Thanks
> --Ken--
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
More information about the Insight-users
mailing list