[Insight-users] Watershed Segmentation - running itkWatershedSegment1.cxx

neha k itkneha1 at yahoo.com
Wed, 3 Mar 2004 06:59:37 -0800 (PST)


--0-2050572023-1078325977=:63756
Content-Type: text/plain; charset=us-ascii

Hi Luis,
 
Thanks for the suggestion.   The example program in ITK/Examples/Segmentation/itkWatershedSegment1.cxx is working properly for breast image.  I get RGB output image. 
 
I have one question about above example. I input the breast image as MetaHeader image (breast.mhd).  Is it correct to read this image as RGB pixel type(program reads image as RGB pixel type) when input image grayscale raw image?.  I am little confused here.  
 
Now about problem in my program of getting output of 0 bytes, should I try to convert the output of watershed to RGB pixel similar to one in above example program. What itk class should I use? (input breast images are grayscale raw images)
 
Thanks,
Neha 

Luis Ibanez <luis.ibanez at kitware.com> wrote:

Hi Neha,


There is no reason for a writer to produce
an image of zero size. Unless an exception
is thrown during the writing process, or
it is actually receiving an image with a
region of size zero.



Please do the following experiment:

Use the example in

Insight/Examples/Segmentation/
WatershedSegmentation1.cxx


for processing your (256 x 256) image.
and let us know what you get.



Thanks


Luis




----------------
neha k wrote:

> Hi Luis,
> 
> Initially, While trying program "itkWatershedSegmentationExample.cxx" I 
> used very small PGM file (24*7) just to see the working of above 
> program, and it gave me 5 output files of RAW format(With Level = 0.50) 
> for Level values 0.10, 0.20...0.50
> 
> But yet I do not know how the original file looks lilke. I tried to use 
> second program "itkWSRawToPNG.cxx" to see the output in PNG format but 
> it crashes on reader->update().
> 
> I am currently reading "Breast.raw" (256*256 - unsigned short-little 
> endian) using MetaImage Reader, then apply 
> AnisotropicDiffusionFilter and then GradientFilter on it.
> Here, I checked by writing the output of those to a file and it gives me 
> correct output with AnisotropicDiffusionFilter->GradientFilter->writer.
> 
> But when I apply watershed as -
> AnisotropicDiffusionFilter->GradientFilter->watershed->writer
> 
> I get the output file of 0 bytes
> 
> I have added the lines suggested by you as follows: (Pls. scroll down 
> for complete code)
> 
> watershed->SetThreshold(threshold);
> watershed->SetLevel(floodLevel); 
> watershed->SetInput(gradientFilter->GetOutput());
> watershed->Update();
> watershed->GetInput()->Print( std::cout );
> watershed->GetOutput()->Print( std::cout ); 
> writer->SetInput(watershed->GetOutput()); 
> writer->update();
> 
> I have attached a word file containing the output of above.
> 
> My Questions
> ---------------------
> 1. To see the segmented output, should I convert output of 
> watershed(after getting file size of original input file), to PNG format?
> 2. What is missing in the my program ?
> 
> Please let me know what is going wrong. Thank you very much,
> 
> Neha
> 
> 
> */Luis Ibanez /* wrote:
> 
> 
> Hi Neha,
> 
> 
> If your image size really
> 
> 24 pixels by 7 pixels ?
> 
> 
> The chances of getting any significant
> segmentation from such a small image are
> very slim.
> 
> 
> You said that the output of the GradientMagnitude
> filter is working ok, did you verified this by
> saving the image to a file ?
> 
> 
> 
> Could you please add the lines:
> 
> watershed->Update();
> watershed->GetInput()->Print( std::cout );
> watershed->GetOutput()->Print( std::cout );
> 
> Put this lines just before you invoke the writer's
> Update() method, execute the program and post the
> results to the list.
> 
> 
> 
> Thanks
> 
> 
> Luis
> 
> 
> 
> -----------------
> neha k wrote:
> 
> > Hi Luis,
> >
> > Due to problem in example program itkWSRawToPNG.cxx, I have written
> > following simple code for experiment to work on RAW grayscale
> file. I
> > am using this pipeline of filters->
> >
> reader--->AnisotropicDiffusionFilter--->GradientMagnitudeFilter--->WaterShed
> >
> > Problem is : Output file is of "0" Bytes. But From
> > GradientMagnitudeFilter, I get desired output. But watershed does
> not
> > give output file of original input size, instead it is Zero.
> > I tried with 3 different values for conductance_term, threshold and
> > Level. But still the output file has 0 bytes.
> >
> > Please let me know if I am missing anything while using watershed.
> >
> > Following the simple code i am using ->
> >
> ***********************************************************************************
> >
> > void segment()
> >
> > {
> >
> > _// declarations_
> >
> > int threshold = 0.30, floodLevel = 0.50;
> >
> > int noOfIterations = 3, retVal = 1, checkExtn =0;
> >
> > char answe r='y', inputFile[255]="breast.mhd", //256*256-little
> endian
> > outputFile[255]="breast_op.mhd";
> >
> > float timeStep = 0.25,
> >
> > conductance = 5.0;
> >
> > typedef itk::Image< InputPixelType, 2 > InputImageType; // float type
> >
> > typedef itk::Image< OutputPixelType, 2 > OutputImageType; //
> float type
> >
> > typedef itk::Image LabeledImageType;
> >
> > typedef itk::Image ScalarImageType;
> >
> > typedef itk::Image WriteImageType;
> >
> > typedef itk::GradientAnisotropicDiffusionImageFilter
> > OutputImageType > FilterType;
> >
> > FilterType::Pointer filter = FilterType::New();
> >
> > // Instantiate Gradient Magnitude Filter typedef
> > itk::GradientMagnitudeImageFilter
> >
> > GradientFilterType;
> >
> > GradientFilterType::Pointer gradientF ilter =
> GradientFilterType::New();
> >
> > typedef itk::WatershedImageFilter WatershedFilterType;
> >
> > WatershedFilterType::Pointer watershed = WatershedFilterType::New();
> >
> > typedef itk::ImageFileWriter< WriteImageType > WriterType; // write
> > output image as short - use rescaler
> >
> > WriterType::Pointer writer = WriterType::New();
> >
> > typedef itk::ImageFileReader< InputImageType > ReaderType; //
> read input
> > image as float
> >
> > ReaderType::Pointer reader = ReaderType::New();
> >
> > reader->SetFileName(inputFile);
> >
> > writer->SetFileName( outputFile );
> >
> > _// Read Input Image of RAW Type (uses MetaImage Header)_
> >
> > try { reader->Update(); }
> >
> > catch( itk::ExceptionObject & e ) {
> >
> > std::cerr << "Exception caught during Raw file reading " <<
> std::endl;
> >
> > ; std::cerr << e << std::endl;
> >
> > std::cout<< "\n\nMake Sure if the file name you specified already
> > exists...\n";
> >
> > return -1;
> >
> > }
> >
> > _// First apply Edge Preserving smoothing filter "Anisotropic
> Diffusion
> > Filter"_
> >
> > filter->SetInput( reader->GetOutput() );
> >
> > filter->SetIterations(noOfIterations); // default value -> 3
> >
> > filter->SetConductanceParameter(conductance); // default value -> 5.0
> >
> > filter->SetTimeStep(timeStep); // default value -> 0.25 for 2-D image
> >
> > _// Pass the output of Anisotropic Diffusion Filter to
> > GradientMagnitudeFilter_
> >
> > gradientFilter->SetInput( filter->GetOutput() );
> >
> > _// Apply Watershed Segmentation_
> >
> > watershed->SetInput(gradientFilter->GetOutput());
> >
> > watershed->SetThreshold(threshold); // 0.30
> >
> > watershed->SetLevel(floodLevel); // 0.50
> >
> > writer->SetInput(watershed->GetOutput());
> >
> > _// Execute the pipeline_
> >
> > try { writer->Update(); }
> >
> > catch( itk::ExceptionObject & excep ){
> >
> > std::cerr << "Exception caught !" << std::endl;
> >
> > std::cerr << excep << std::endl;
> >
> > retVal = -1;
> >
> > }
> >
> > }
> >
> >
> >
> ***********************************************************************************
> >
> > */Joshua Cates /* wrote:
> >
> > Hi,
> >
> > Thanks for the feedback on the watershed example. This code is
> old and
> > probably in need of updating for more recent developments in the
> ITK IO
> > classes. I will take a look.
> >
> > Josh.
> >
> > On Mon, 23 Feb 2004, n eha k wrote:
> >
> > >
> > > Hi All,
> > >
> > > I am trying to run exampleI programs in Watershed segmetnation. I
> > tried
> > > the example program with Input file as PGM file (in.pgm) which
> is of
> > > size (24*7). When I run itkWatershedSegmentationExample.cxx, I
> get 5
> > > output files of raw format (with level = 0.50). When I set any of
> > those
> > > 5 output files as an input file to second program
> > itkWSRawToPNG.cxx so
> > > that I can convert it to png file to view, program crashes( on
> > statement
> > > reader_update()). What should be the input file given to this
> second
> > > program? Also, if i want to segment the raw br est images, what
> > reader
> > > should I use and how should i generate the output files? What
> > filters,
> > > mappers should I use to apply watershed segmentation on grayscale
> > breast
> > > images of Raw for mat to find out if there is any lesion inside
> > the brest
> > > image? (Currently, I am using MetaImageReader to apply other ITK
> > filters
> > > on breast images.)
> > >
> > > Any suggestions are appreiated.
> > >
> > > My input PGM file is as follows
> > >
> > >
> >
> ***************************************************************************************
> > >
> > > P2
> > >
> > > 24 7
> > >
> > > 15
> > >
> > > 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> > >
> > > 0 3 3 3 3 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 15 15 15 0
> > >
> > > 0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 15 0
> > >
> > > 0 3 3 3 0 0 0 7 7 7 0 0 0 11 11 11 0 0 0 15 15 15 15 0
> > >
> > > 0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 0 0
> > > *> 0 3 0 0 0 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 0 0 0 0
> > >
> & gt; > 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> > >
> > >
> > >
> > >
> >
> ***************************************************************************************
> >
> > >
> > > Thanks,
> > >
> > > Neha
> > >
> > >
> > > ---------------------------------
> > > Do you Yahoo!?
> > > Yahoo! Mail SpamGuard - Read only the mail you want.
> >
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users at itk.org
> > http://www.itk.org/mailman/listinfo/insight-users*
> >
> >
> ------------------------------------------------------------------------
> > *Do you Yahoo!?
> > Get better spam protection with Yahoo! Mail
> > *
> 
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 
> ------------------------------------------------------------------------
> Do you Yahoo!?
> Get better spam protection with Yahoo! Mail 
> 
> {\rtf1\ansi\ansicpg1252\uc1\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 
> 02020603050405020304}Times New Roman;}{\f36\froman\fcharset238\fprq2 
> Times New Roman CE;} {\f37\froman\fcharset204\fprq2 Times New Roman 
> Cyr;}{\f39\froman\fcharset161\fprq2 Times New Roman 
> Greek;}{\f40\froman\fcharset162\fprq2 Times New Roman 
> Tur;}{\f41\froman\fcharset177\fprq2 Times New Roman (Hebrew);} 
> {\f42\froman\fcharset178\fprq2 Times New Roman 
> (Arabic);}{\f43\froman\fcharset186\fprq2 Times New Roman 
> Baltic;}{\f44\froman\fcharset163\fprq2 Times New Roman 
> (Vietnamese);}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255; 
> \red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0; 
> \red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{\ql 
> \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 
> \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \snext0 
> Normal;}{\*\cs10 \additive \ssemihidden Default Paragraph 
> Font;}{\*\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\trcbpat1\trcfpat1\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv 
> \ql 
> \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 
> \fs20\lang1024\langfe1024\cgrid\langnp1024\langfenp1024 \snext11 
> \ssemihidden Normal Table;}}{\*\rsidtbl 
> \rsid11687438\rsid15806933}{\*\generator Microsoft Word 
> 10.0.3416;}{\info {\author shilpa}{\operator 
> shilpa}{\creatim\yr2004\mo3\dy1\hr17\min44}{\revtim\yr2004\mo3\dy1\hr17\min45}{\version2}{\edmins1}{\nofpages2}{\nofwords294}{\nofchars1678}{\*\company 
> WPI}{\nofcharsws1969}{\vern16453}} 
> \widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\horzdoc\dghspace120\dgvspace120\dghorigin1701\dgvorigin1984\dghshow0\dgvshow3\jcompress\viewkind4\viewscale90\nolnhtadjtbl\rsidroot15806933 
> \fet0\sectd \linex0\sectdefaultcl\sftnbj 
> {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang {\pntxta 
> .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang {\pntxta 
> .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang {\pntxta 
> .}}{\*\pnseclvl4 \pnlcltr\pnstart1\pnindent720\pnhang {\pntxta 
> )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta 
> )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta 
> )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (} {\pntxta 
> )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta 
> )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta 
> )}}\pard\plain \ql 
> \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid15806933 
> \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 
> {\insrsid15806933\charrsid15806933 Enter Input File Name with 
> extention(.mhd) only -->c:\\breast.mhd \par Enter Output File Name with 
> extention(.mhd) only -->c:\\breast_segment.mhd}{\insrsid15806933 \par 
> ----------------------------------------------------------------------------------------------------}{\insrsid15806933\charrsid15806933 
> \par Image (00225EE0) \par Reference Count: 3 \par Modified Time: 147 
> \par Debug: Off \par Observers: \par none \par Source: (00225660) \par 
> Source output index: 0 \par Release Data: Off \par Data Released: False 
> \par Global Release Data: Off \par PipelineMTime: 133 \par UpdateTime: 
> 149 \par LastRequestedRegionWasOutsideOfTheBufferedRegion: 0 \par 
> LargestPossibleRegion: \par Dimension: 2 \par Index: [0, 0] \par Size: 
> [256, 256] \par BufferedRegion: \par Dimension: 2 \par Index: [0, 0] 
> \par Size: [256, 256] \par RequestedRegion: \par Dimension: 2 \par 
> Index: [0, 0] \par Size: [256, 256] \par Origin: [0, 0] \par Spacing: 
> [0.703, 0.585] \par PixelContainer: ImportImageContainer (002254C8) \par 
> Reference Count: 2 \par Modified Time: 148 \par Debug: Off \par 
> Observers: \par none \par Pointer: 002254F4 \par Container manages 
> memory: true \par Size: 65536 \par Capacity: 65536 \par \par Image 
> (00226DB8) \par Reference Count: 1 \par Modified Time: 190 \par Debug: 
> Off \par Observers: \par none \par Source: (00226068) \par Source output 
> index: 0 \par Release Data: Off \par Data Released: False \par Global 
> Release Data: Off \par PipelineMTime: 133 \par UpdateTime: 191 \par 
> LastRequestedRegionWasOutsideOfTheBufferedRegion: 1 \par 
> LargestPossibleRegion: \par Dimension: 2 \par Index: [0, 0] \par Size: 
> [256, 256] \par BufferedRegion: \par Dimension: 2 \par Index: [0, 0] 
> \par Size: [256, 256] \par RequestedRegion: \par Dimension: 2 \par 
> Index: [0, 0] \par Size: [256, 256] \par Origin: [0, 0] \par Spacing: 
> [0.703, 0.585] \par PixelContainer: ImportImageContainer (01A9FFC0) \par 
> Reference Count: 3 \par Modified Time: 187 \par Debug: Off \par 
> Observers: \par none \par Pointer: 01A9FFEC \par Container manages 
> memory: true \par Size: 65536 \par Capacity: 65536 \par 
> }{\insrsid15806933 
> ----------------------------------------------------------------------------------------------------}{\insrsid15806933\charrsid15806933 
> \par \par File succesfully writen ! \par Press any key to 
> continue}{\insrsid15806933\charrsid15806933 \par }}



_______________________________________________
Insight-users mailing list
Insight-users at itk.org
http://www.itk.org/mailman/listinfo/insight-users

---------------------------------
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online
--0-2050572023-1078325977=:63756
Content-Type: text/html; charset=us-ascii

<DIV>Hi Luis,</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thanks for the suggestion.&nbsp;&nbsp; The example program in ITK/Examples/Segmentation/itkWatershedSegment1.cxx is working properly for breast image.&nbsp; I get RGB output image. </DIV>
<DIV>&nbsp;</DIV>
<DIV>I have one question about above example. I input the breast image as MetaHeader image (breast.mhd).&nbsp; Is it correct to read this image as RGB pixel type(program reads image as RGB pixel type) when input image grayscale raw image?.&nbsp; I am little confused here.&nbsp; </DIV>
<DIV>&nbsp;</DIV>
<DIV>Now about problem in my program of getting output of 0 bytes, should I try to convert the output of watershed to RGB pixel similar to one in above example program. What itk class should I use? (input breast images are grayscale raw images)</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thanks,</DIV>
<DIV>Neha&nbsp;<BR><BR><B><I>Luis Ibanez &lt;luis.ibanez at kitware.com&gt;</I></B> wrote:</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid"><BR>Hi Neha,<BR><BR><BR>There is no reason for a writer to produce<BR>an image of zero size. Unless an exception<BR>is thrown during the writing process, or<BR>it is actually receiving an image with a<BR>region of size zero.<BR><BR><BR><BR>Please do the following experiment:<BR><BR>Use the example in<BR><BR>Insight/Examples/Segmentation/<BR>WatershedSegmentation1.cxx<BR><BR><BR>for processing your (256 x 256) image.<BR>and let us know what you get.<BR><BR><BR><BR>Thanks<BR><BR><BR>Luis<BR><BR><BR><BR><BR>----------------<BR>neha k wrote:<BR><BR>&gt; Hi Luis,<BR>&gt; <BR>&gt; Initially, While trying program "itkWatershedSegmentationExample.cxx" I <BR>&gt; used very small PGM file (24*7) just to see the working of above <BR>&gt; program, and it gave me 5 output files of RAW format(With Level = 0.50) <BR>&gt; for Level values 0.10, 0.20...0.50<BR>&gt; <BR>&gt; But yet I do not know how
 the original file looks lilke. I tried to use <BR>&gt; second program "itkWSRawToPNG.cxx" to see the output in PNG format but <BR>&gt; it crashes on reader-&gt;update().<BR>&gt; <BR>&gt; I am currently reading "Breast.raw" (256*256 - unsigned short-little <BR>&gt; endian) using MetaImage Reader, then apply <BR>&gt; AnisotropicDiffusionFilter and then GradientFilter on it.<BR>&gt; Here, I checked by writing the output of those to a file and it gives me <BR>&gt; correct output with AnisotropicDiffusionFilter-&gt;GradientFilter-&gt;writer.<BR>&gt; <BR>&gt; But when I apply watershed as -<BR>&gt; AnisotropicDiffusionFilter-&gt;GradientFilter-&gt;watershed-&gt;writer<BR>&gt; <BR>&gt; I get the output file of 0 bytes<BR>&gt; <BR>&gt; I have added the lines suggested by you as follows: (Pls. scroll down <BR>&gt; for complete code)<BR>&gt; <BR>&gt; watershed-&gt;SetThreshold(threshold);<BR>&gt; watershed-&gt;SetLevel(floodLevel); <BR>&gt;
 watershed-&gt;SetInput(gradientFilter-&gt;GetOutput());<BR>&gt; watershed-&gt;Update();<BR>&gt; watershed-&gt;GetInput()-&gt;Print( std::cout );<BR>&gt; watershed-&gt;GetOutput()-&gt;Print( std::cout ); <BR>&gt; writer-&gt;SetInput(watershed-&gt;GetOutput()); <BR>&gt; writer-&gt;update();<BR>&gt; <BR>&gt; I have attached a word file containing the output of above.<BR>&gt; <BR>&gt; My Questions<BR>&gt; ---------------------<BR>&gt; 1. To see the segmented output, should I convert output of <BR>&gt; watershed(after getting file size of original input file), to PNG format?<BR>&gt; 2. What is missing in the my program ?<BR>&gt; <BR>&gt; Please let me know what is going wrong. Thank you very much,<BR>&gt; <BR>&gt; Neha<BR>&gt; <BR>&gt; <BR>&gt; */Luis Ibanez <LUIS.IBANEZ at KITWARE.COM>/* wrote:<BR>&gt; <BR>&gt; <BR>&gt; Hi Neha,<BR>&gt; <BR>&gt; <BR>&gt; If your image size really<BR>&gt; <BR>&gt; 24 pixels by 7 pixels ?<BR>&gt; <BR>&gt; <BR>&gt; The chances of getting any
 significant<BR>&gt; segmentation from such a small image are<BR>&gt; very slim.<BR>&gt; <BR>&gt; <BR>&gt; You said that the output of the GradientMagnitude<BR>&gt; filter is working ok, did you verified this by<BR>&gt; saving the image to a file ?<BR>&gt; <BR>&gt; <BR>&gt; <BR>&gt; Could you please add the lines:<BR>&gt; <BR>&gt; watershed-&gt;Update();<BR>&gt; watershed-&gt;GetInput()-&gt;Print( std::cout );<BR>&gt; watershed-&gt;GetOutput()-&gt;Print( std::cout );<BR>&gt; <BR>&gt; Put this lines just before you invoke the writer's<BR>&gt; Update() method, execute the program and post the<BR>&gt; results to the list.<BR>&gt; <BR>&gt; <BR>&gt; <BR>&gt; Thanks<BR>&gt; <BR>&gt; <BR>&gt; Luis<BR>&gt; <BR>&gt; <BR>&gt; <BR>&gt; -----------------<BR>&gt; neha k wrote:<BR>&gt; <BR>&gt; &gt; Hi Luis,<BR>&gt; &gt;<BR>&gt; &gt; Due to problem in example program itkWSRawToPNG.cxx, I have written<BR>&gt; &gt; following simple code for experiment to work on RAW grayscale<BR>&gt; file. I<BR>&gt;
 &gt; am using this pipeline of filters-&gt;<BR>&gt; &gt;<BR>&gt; reader---&gt;AnisotropicDiffusionFilter---&gt;GradientMagnitudeFilter---&gt;WaterShed<BR>&gt; &gt;<BR>&gt; &gt; Problem is : Output file is of "0" Bytes. But From<BR>&gt; &gt; GradientMagnitudeFilter, I get desired output. But watershed does<BR>&gt; not<BR>&gt; &gt; give output file of original input size, instead it is Zero.<BR>&gt; &gt; I tried with 3 different values for conductance_term, threshold and<BR>&gt; &gt; Level. But still the output file has 0 bytes.<BR>&gt; &gt;<BR>&gt; &gt; Please let me know if I am missing anything while using watershed.<BR>&gt; &gt;<BR>&gt; &gt; Following the simple code i am using -&gt;<BR>&gt; &gt;<BR>&gt; ***********************************************************************************<BR>&gt; &gt;<BR>&gt; &gt; void segment()<BR>&gt; &gt;<BR>&gt; &gt; {<BR>&gt; &gt;<BR>&gt; &gt; _// declarations_<BR>&gt; &gt;<BR>&gt; &gt; int threshold = 0.30, floodLevel = 0.50;<BR>&gt;
 &gt;<BR>&gt; &gt; int noOfIterations = 3, retVal = 1, checkExtn =0;<BR>&gt; &gt;<BR>&gt; &gt; char answe r='y', inputFile[255]="breast.mhd", //256*256-little<BR>&gt; endian<BR>&gt; &gt; outputFile[255]="breast_op.mhd";<BR>&gt; &gt;<BR>&gt; &gt; float timeStep = 0.25,<BR>&gt; &gt;<BR>&gt; &gt; conductance = 5.0;<BR>&gt; &gt;<BR>&gt; &gt; typedef itk::Image&lt; InputPixelType, 2 &gt; InputImageType; // float type<BR>&gt; &gt;<BR>&gt; &gt; typedef itk::Image&lt; OutputPixelType, 2 &gt; OutputImageType; //<BR>&gt; float type<BR>&gt; &gt;<BR>&gt; &gt; typedef itk::Image LabeledImageType;<BR>&gt; &gt;<BR>&gt; &gt; typedef itk::Image ScalarImageType;<BR>&gt; &gt;<BR>&gt; &gt; typedef itk::Image WriteImageType;<BR>&gt; &gt;<BR>&gt; &gt; typedef itk::GradientAnisotropicDiffusionImageFilter<BR>&gt; &gt; OutputImageType &gt; FilterType;<BR>&gt; &gt;<BR>&gt; &gt; FilterType::Pointer filter = FilterType::New();<BR>&gt; &gt;<BR>&gt; &gt; // Instantiate Gradient Magnitude Filter typedef<BR>&gt;
 &gt; itk::GradientMagnitudeImageFilter<BR>&gt; &gt;<BR>&gt; &gt; GradientFilterType;<BR>&gt; &gt;<BR>&gt; &gt; GradientFilterType::Pointer gradientF ilter =<BR>&gt; GradientFilterType::New();<BR>&gt; &gt;<BR>&gt; &gt; typedef itk::WatershedImageFilter WatershedFilterType;<BR>&gt; &gt;<BR>&gt; &gt; WatershedFilterType::Pointer watershed = WatershedFilterType::New();<BR>&gt; &gt;<BR>&gt; &gt; typedef itk::ImageFileWriter&lt; WriteImageType &gt; WriterType; // write<BR>&gt; &gt; output image as short - use rescaler<BR>&gt; &gt;<BR>&gt; &gt; WriterType::Pointer writer = WriterType::New();<BR>&gt; &gt;<BR>&gt; &gt; typedef itk::ImageFileReader&lt; InputImageType &gt; ReaderType; //<BR>&gt; read input<BR>&gt; &gt; image as float<BR>&gt; &gt;<BR>&gt; &gt; ReaderType::Pointer reader = ReaderType::New();<BR>&gt; &gt;<BR>&gt; &gt; reader-&gt;SetFileName(inputFile);<BR>&gt; &gt;<BR>&gt; &gt; writer-&gt;SetFileName( outputFile );<BR>&gt; &gt;<BR>&gt; &gt; _// Read Input Image of RAW Type (uses
 MetaImage Header)_<BR>&gt; &gt;<BR>&gt; &gt; try { reader-&gt;Update(); }<BR>&gt; &gt;<BR>&gt; &gt; catch( itk::ExceptionObject &amp; e ) {<BR>&gt; &gt;<BR>&gt; &gt; std::cerr &lt;&lt; "Exception caught during Raw file reading " &lt;&lt;<BR>&gt; std::endl;<BR>&gt; &gt;<BR>&gt; &gt; ; std::cerr &lt;&lt; e &lt;&lt; std::endl;<BR>&gt; &gt;<BR>&gt; &gt; std::cout&lt;&lt; "\n\nMake Sure if the file name you specified already<BR>&gt; &gt; exists...\n";<BR>&gt; &gt;<BR>&gt; &gt; return -1;<BR>&gt; &gt;<BR>&gt; &gt; }<BR>&gt; &gt;<BR>&gt; &gt; _// First apply Edge Preserving smoothing filter "Anisotropic<BR>&gt; Diffusion<BR>&gt; &gt; Filter"_<BR>&gt; &gt;<BR>&gt; &gt; filter-&gt;SetInput( reader-&gt;GetOutput() );<BR>&gt; &gt;<BR>&gt; &gt; filter-&gt;SetIterations(noOfIterations); // default value -&gt; 3<BR>&gt; &gt;<BR>&gt; &gt; filter-&gt;SetConductanceParameter(conductance); // default value -&gt; 5.0<BR>&gt; &gt;<BR>&gt; &gt; filter-&gt;SetTimeStep(timeStep); // default value -&gt;
 0.25 for 2-D image<BR>&gt; &gt;<BR>&gt; &gt; _// Pass the output of Anisotropic Diffusion Filter to<BR>&gt; &gt; GradientMagnitudeFilter_<BR>&gt; &gt;<BR>&gt; &gt; gradientFilter-&gt;SetInput( filter-&gt;GetOutput() );<BR>&gt; &gt;<BR>&gt; &gt; _// Apply Watershed Segmentation_<BR>&gt; &gt;<BR>&gt; &gt; watershed-&gt;SetInput(gradientFilter-&gt;GetOutput());<BR>&gt; &gt;<BR>&gt; &gt; watershed-&gt;SetThreshold(threshold); // 0.30<BR>&gt; &gt;<BR>&gt; &gt; watershed-&gt;SetLevel(floodLevel); // 0.50<BR>&gt; &gt;<BR>&gt; &gt; writer-&gt;SetInput(watershed-&gt;GetOutput());<BR>&gt; &gt;<BR>&gt; &gt; _// Execute the pipeline_<BR>&gt; &gt;<BR>&gt; &gt; try { writer-&gt;Update(); }<BR>&gt; &gt;<BR>&gt; &gt; catch( itk::ExceptionObject &amp; excep ){<BR>&gt; &gt;<BR>&gt; &gt; std::cerr &lt;&lt; "Exception caught !" &lt;&lt; std::endl;<BR>&gt; &gt;<BR>&gt; &gt; std::cerr &lt;&lt; excep &lt;&lt; std::endl;<BR>&gt; &gt;<BR>&gt; &gt; retVal = -1;<BR>&gt; &gt;<BR>&gt; &gt; }<BR>&gt;
 &gt;<BR>&gt; &gt; }<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; ***********************************************************************************<BR>&gt; &gt;<BR>&gt; &gt; */Joshua Cates /* wrote:<BR>&gt; &gt;<BR>&gt; &gt; Hi,<BR>&gt; &gt;<BR>&gt; &gt; Thanks for the feedback on the watershed example. This code is<BR>&gt; old and<BR>&gt; &gt; probably in need of updating for more recent developments in the<BR>&gt; ITK IO<BR>&gt; &gt; classes. I will take a look.<BR>&gt; &gt;<BR>&gt; &gt; Josh.<BR>&gt; &gt;<BR>&gt; &gt; On Mon, 23 Feb 2004, n eha k wrote:<BR>&gt; &gt;<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; Hi All,<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; I am trying to run exampleI programs in Watershed segmetnation. I<BR>&gt; &gt; tried<BR>&gt; &gt; &gt; the example program with Input file as PGM file (in.pgm) which<BR>&gt; is of<BR>&gt; &gt; &gt; size (24*7). When I run itkWatershedSegmentationExample.cxx, I<BR>&gt; get 5<BR>&gt; &gt; &gt; output files of raw format (with level =
 0.50). When I set any of<BR>&gt; &gt; those<BR>&gt; &gt; &gt; 5 output files as an input file to second program<BR>&gt; &gt; itkWSRawToPNG.cxx so<BR>&gt; &gt; &gt; that I can convert it to png file to view, program crashes( on<BR>&gt; &gt; statement<BR>&gt; &gt; &gt; reader_update()). What should be the input file given to this<BR>&gt; second<BR>&gt; &gt; &gt; program? Also, if i want to segment the raw br est images, what<BR>&gt; &gt; reader<BR>&gt; &gt; &gt; should I use and how should i generate the output files? What<BR>&gt; &gt; filters,<BR>&gt; &gt; &gt; mappers should I use to apply watershed segmentation on grayscale<BR>&gt; &gt; breast<BR>&gt; &gt; &gt; images of Raw for mat to find out if there is any lesion inside<BR>&gt; &gt; the brest<BR>&gt; &gt; &gt; image? (Currently, I am using MetaImageReader to apply other ITK<BR>&gt; &gt; filters<BR>&gt; &gt; &gt; on breast images.)<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; Any suggestions are appreiated.<BR>&gt; &gt; &gt;<BR>&gt; &gt;
 &gt; My input PGM file is as follows<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt;<BR>&gt; &gt;<BR>&gt; ***************************************************************************************<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; P2<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; 24 7<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; 15<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; 0 3 3 3 3 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 15 15 15 0<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; 0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 15 0<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; 0 3 3 3 0 0 0 7 7 7 0 0 0 11 11 11 0 0 0 15 15 15 15 0<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; 0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 0 0<BR>&gt; &gt; &gt; *&gt; 0 3 0 0 0 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 0 0 0 0<BR>&gt; &gt; &gt;<BR>&gt; &amp; gt; &gt; 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt;<BR>&gt;
 &gt;<BR>&gt; ***************************************************************************************<BR>&gt; &gt;<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; Thanks,<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; Neha<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; ---------------------------------<BR>&gt; &gt; &gt; Do you Yahoo!?<BR>&gt; &gt; &gt; Yahoo! Mail SpamGuard - Read only the mail you want.<BR>&gt; &gt;<BR>&gt; &gt; _______________________________________________<BR>&gt; &gt; Insight-users mailing list<BR>&gt; &gt; Insight-users at itk.org<BR>&gt; &gt; http://www.itk.org/mailman/listinfo/insight-users*<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; ------------------------------------------------------------------------<BR>&gt; &gt; *Do you Yahoo!?<BR>&gt; &gt; Get better spam protection with Yahoo! Mail<BR>&gt; &gt; *<BR>&gt; <BR>&gt; <BR>&gt; <BR>&gt; _______________________________________________<BR>&gt; Insight-users mailing list<BR>&gt; Insight-users at itk.org<BR>&gt;
 http://www.itk.org/mailman/listinfo/insight-users<BR>&gt; <BR>&gt; ------------------------------------------------------------------------<BR>&gt; Do you Yahoo!?<BR>&gt; Get better spam protection with Yahoo! Mail <BR>&gt; <HTTP: tools antispam.yahoo.com *http: mailtag_us us.rd.yahoo.com><BR>&gt; {\rtf1\ansi\ansicpg1252\uc1\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose <BR>&gt; 02020603050405020304}Times New Roman;}{\f36\froman\fcharset238\fprq2 <BR>&gt; Times New Roman CE;} {\f37\froman\fcharset204\fprq2 Times New Roman <BR>&gt; Cyr;}{\f39\froman\fcharset161\fprq2 Times New Roman <BR>&gt; Greek;}{\f40\froman\fcharset162\fprq2 Times New Roman <BR>&gt; Tur;}{\f41\froman\fcharset177\fprq2 Times New Roman (Hebrew);} <BR>&gt; {\f42\froman\fcharset178\fprq2 Times New Roman <BR>&gt; (Arabic);}{\f43\froman\fcharset186\fprq2 Times New Roman <BR>&gt; Baltic;}{\f44\froman\fcharset163\fprq2 Times New Roman <BR>&gt;
 (Vietnamese);}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255; <BR>&gt; \red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0; <BR>&gt; \red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{\ql <BR>&gt; \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 <BR>&gt; \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \snext0 <BR>&gt; Normal;}{\*\cs10 \additive \ssemihidden Default Paragraph <BR>&gt; Font;}{\*\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\trcbpat1\trcfpat1\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv <BR>&gt; \ql <BR>&gt; \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 <BR>&gt;
 \fs20\lang1024\langfe1024\cgrid\langnp1024\langfenp1024 \snext11 <BR>&gt; \ssemihidden Normal Table;}}{\*\rsidtbl <BR>&gt; \rsid11687438\rsid15806933}{\*\generator Microsoft Word <BR>&gt; 10.0.3416;}{\info {\author shilpa}{\operator <BR>&gt; shilpa}{\creatim\yr2004\mo3\dy1\hr17\min44}{\revtim\yr2004\mo3\dy1\hr17\min45}{\version2}{\edmins1}{\nofpages2}{\nofwords294}{\nofchars1678}{\*\company <BR>&gt; WPI}{\nofcharsws1969}{\vern16453}} <BR>&gt; \widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\horzdoc\dghspace120\dgvspace120\dghorigin1701\dgvorigin1984\dghshow0\dgvshow3\jcompress\viewkind4\viewscale90\nolnhtadjtbl\rsidroot15806933 <BR>&gt; \fet0\sectd \linex0\sectdefaultcl\sftnbj <BR>&gt; {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang {\pntxta <BR>&gt; .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang {\pntxta <BR>&gt; .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang {\pntxta <BR>&gt; .}}{\*\pnseclvl4 \pnlcltr\pnstart1\pnindent720\pnhang
 {\pntxta <BR>&gt; )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta <BR>&gt; )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta <BR>&gt; )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (} {\pntxta <BR>&gt; )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta <BR>&gt; )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta <BR>&gt; )}}\pard\plain \ql <BR>&gt; \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid15806933 <BR>&gt; \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 <BR>&gt; {\insrsid15806933\charrsid15806933 Enter Input File Name with <BR>&gt; extention(.mhd) only --&gt;c:\\breast.mhd \par Enter Output File Name with <BR>&gt; extention(.mhd) only --&gt;c:\\breast_segment.mhd}{\insrsid15806933 \par <BR>&gt; ----------------------------------------------------------------------------------------------------}{\insrsid15806933\charrsid15806933 <BR>&gt;
 \par Image (00225EE0) \par Reference Count: 3 \par Modified Time: 147 <BR>&gt; \par Debug: Off \par Observers: \par none \par Source: (00225660) \par <BR>&gt; Source output index: 0 \par Release Data: Off \par Data Released: False <BR>&gt; \par Global Release Data: Off \par PipelineMTime: 133 \par UpdateTime: <BR>&gt; 149 \par LastRequestedRegionWasOutsideOfTheBufferedRegion: 0 \par <BR>&gt; LargestPossibleRegion: \par Dimension: 2 \par Index: [0, 0] \par Size: <BR>&gt; [256, 256] \par BufferedRegion: \par Dimension: 2 \par Index: [0, 0] <BR>&gt; \par Size: [256, 256] \par RequestedRegion: \par Dimension: 2 \par <BR>&gt; Index: [0, 0] \par Size: [256, 256] \par Origin: [0, 0] \par Spacing: <BR>&gt; [0.703, 0.585] \par PixelContainer: ImportImageContainer (002254C8) \par <BR>&gt; Reference Count: 2 \par Modified Time: 148 \par Debug: Off \par <BR>&gt; Observers: \par none \par Pointer: 002254F4 \par Container manages <BR>&gt; memory: true \par Size: 65536 \par Capacity: 65536 \par
 \par Image <BR>&gt; (00226DB8) \par Reference Count: 1 \par Modified Time: 190 \par Debug: <BR>&gt; Off \par Observers: \par none \par Source: (00226068) \par Source output <BR>&gt; index: 0 \par Release Data: Off \par Data Released: False \par Global <BR>&gt; Release Data: Off \par PipelineMTime: 133 \par UpdateTime: 191 \par <BR>&gt; LastRequestedRegionWasOutsideOfTheBufferedRegion: 1 \par <BR>&gt; LargestPossibleRegion: \par Dimension: 2 \par Index: [0, 0] \par Size: <BR>&gt; [256, 256] \par BufferedRegion: \par Dimension: 2 \par Index: [0, 0] <BR>&gt; \par Size: [256, 256] \par RequestedRegion: \par Dimension: 2 \par <BR>&gt; Index: [0, 0] \par Size: [256, 256] \par Origin: [0, 0] \par Spacing: <BR>&gt; [0.703, 0.585] \par PixelContainer: ImportImageContainer (01A9FFC0) \par <BR>&gt; Reference Count: 3 \par Modified Time: 187 \par Debug: Off \par <BR>&gt; Observers: \par none \par Pointer: 01A9FFEC \par Container manages <BR>&gt; memory: true \par Size: 65536 \par Capacity:
 65536 \par <BR>&gt; }{\insrsid15806933 <BR>&gt; ----------------------------------------------------------------------------------------------------}{\insrsid15806933\charrsid15806933 <BR>&gt; \par \par File succesfully writen ! \par Press any key to <BR>&gt; continue}{\insrsid15806933\charrsid15806933 \par }}<BR><BR><BR><BR>_______________________________________________<BR>Insight-users mailing list<BR>Insight-users at itk.org<BR>http://www.itk.org/mailman/listinfo/insight-users</BLOCKQUOTE><p><hr SIZE=1>
Do you Yahoo!?<br>
Yahoo! Finance: <a href="http://us.rd.yahoo.com/evt=22055/*http://taxes.yahoo.com/filing.html">Get your refund fast by filing online</a>
--0-2050572023-1078325977=:63756--