<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>
<div>Dear ,</div>
<div> </div>
<div>could you please describe the problem you have with your code? The only things I see immediately is that you should write</div>
<div> </div>
<div><br/>
const char * outfile = "C:\\Users\\zhq\\Desktop\\2.jpg";</div>
<div> </div>
<div>...</div>
<div> </div>
<div>write->SetImageIO(jpgIO);</div>
<div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div>Best,</div>
<div>Robert</div>
<div> </div>
<div name="quote" style="margin:10px 5px 5px 10px; padding: 10px 0 10px 10px; border-left:2px solid #C3D9E5; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="margin:0 0 10px 0;"><b>Gesendet:</b> Mittwoch, 24. Juli 2013 um 10:31 Uhr<br/>
<b>Von:</b> 章强 <15891495523@126.com><br/>
<b>An:</b> insight-users@itk.org<br/>
<b>Betreff:</b> [Insight-users] I want to fulfill a function with ITK , read from a dcm picture and write to a jpg picture .Please help !</div>
<div name="quoted-content">
<div style="line-height: 1.7;color: rgb(0,0,0);font-size: 14.0px;font-family: arial;">Hello , I have just started learning ITK , and I have some difficulty with it .
<div> Now ,I want to fulfill a function with ITK , read from a dcm picture and write to a jpg picture . My code has some problem ,could you please correct it ? the following is my code :</div>
<div>
<div> </div>
<div>#include "itkImageFileReader.h"</div>
<div>#include "itkImageFileWriter.h"</div>
<div>#include "itkRescaleIntensityImageFilter.h"</div>
<div>#include "itkGDCMImageIO.h"</div>
<div>#include "itkJPEGImageIO.h"</div>
<div> </div>
<div> </div>
<div>void main( )</div>
<div>{</div>
<div> typedef signed short InputPixelType;</div>
<div> const unsigned int InputDimension = 2;</div>
<div> </div>
<div> typedef itk::Image< InputPixelType, InputDimension > InputImageType;</div>
<div> </div>
<div> typedef itk::ImageFileReader< InputImageType > ReaderType;</div>
<div> </div>
<div> ReaderType::Pointer reader = ReaderType::New();</div>
<div> </div>
<div> const char * filename = "C:\\Users\\zhq\\Desktop\\data\\SNAP_CR\\E403434298\\E403434298S1901I301.dcm";</div>
<div> </div>
<div> reader->SetFileName( filename );</div>
<div> </div>
<div> typedef itk::GDCMImageIO ImageIOType;</div>
<div> </div>
<div> ImageIOType::Pointer gdcmImageIO = ImageIOType::New();</div>
<div> </div>
<div> reader->SetImageIO( gdcmImageIO );</div>
<div> </div>
<div> reader->Update();</div>
<div> </div>
<div> typedef itk::ImageFileWriter<InputImageType> WriteType ;</div>
<div> </div>
<div> WriteType::Pointer write = WriteType::New();</div>
<div> </div>
<div> const char * outfile = "C:\\Users\\zhq\\Desktop\\2.dcm";</div>
<div> </div>
<div> write->SetFileName(outfile);</div>
<div> </div>
<div> typedef itk::JPEGImageIO OutPutIOType ; </div>
<div> </div>
<div> OutPutIOType::Pointer jpgIO = OutPutIOType::New();</div>
<div> </div>
<div> write->SetImageIO(gdcmImageIO);</div>
<div> </div>
<div> write->SetInput(reader->GetOutput());</div>
<div> </div>
<div> write->Update();</div>
<div>}</div>
</div>
</div>
</div>
</div>
</div>
</div></div></body></html>