Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

need help


  • Please log in to reply
7 replies to this topic

#1 sassou

sassou

  • Members
  • 9 posts
  • OFFLINE
  •  
  • Local time:05:25 AM

Posted 05 August 2009 - 07:44 AM

Hi,
I have this program and i can't undrstand it , itry to run it but i don't know how can i gives arguments exactly.also i contains errors can some one help me to explain to me the code step by step and help me to correct it
: #if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif

#ifdef __BORLANDC__
#define ITK_LEAN_AND_MEAN
#endif


#include "itkOrientedImage.h"
#include "itkGDCMImageIO.h"
#include "itkGDCMSeriesFileNames.h"
#include "itkImageSeriesReader.h"
#include "itkImageFileWriter.h"


#include "itkRescaleIntensityImageFilter.h"
#include "itkDiscreteGaussianImageFilter.h"


int main( int argc, char* argv[] )
{

 /* if( argc < 3 )
	{
	std::cerr << "Usage: " << std::endl;
	std::cerr << argv[0] << " DicomDirectory  outputFileName  [seriesName]" << std::endl;
	return EXIT_FAILURE;
	}

*/

	
  typedef signed short	PixelType;
  const unsigned int	  Dimension = 3;

  typedef itk::OrientedImage< PixelType, Dimension >		 ImageType;

  typedef itk::ImageSeriesReader< ImageType >		ReaderType;
  ReaderType::Pointer reader = ReaderType::New();

  typedef itk::GDCMImageIO	   ImageIOType;
  ImageIOType::Pointer dicomIO = ImageIOType::New();
  
  reader->SetImageIO( dicomIO );

  typedef itk::GDCMSeriesFileNames NamesGeneratorType;
  NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();

  nameGenerator->SetUseSeriesDetails( true );
  nameGenerator->AddSeriesRestriction("0008|0021" );
  
  nameGenerator->SetDirectory( argv[1] );

  

  try
	{
	std::cout << std::endl << "The directory: " << std::endl;
	std::cout << std::endl << argv[1] << std::endl;
	std::cout << "Contains the following DICOM Series: ";
	std::cout << std::endl << std::endl;



	typedef std::vector< std::string >	SeriesIdContainer;
	
	const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();
	
	SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();
	SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();
	while( seriesItr != seriesEnd )
	  {
	  std::cout << seriesItr->c_str() << std::endl;
	  seriesItr++;
	  }


	std::string seriesIdentifier;

	/*if( argc > 3 ) // If no optional series identifier
	  {
	  seriesIdentifier = argv[3];
	  }
	else
	  {
	  seriesIdentifier = seriesUID.begin()->c_str();
	  }*/
 seriesIdentifier = seriesUID.begin()->c_str();


	std::cout << std::endl << std::endl;
	std::cout << "Now reading series: " << std::endl << std::endl;
	std::cout << seriesIdentifier << std::endl;
	std::cout << std::endl << std::endl;





	typedef std::vector< std::string >   FileNamesContainer;
	FileNamesContainer fileNames;

	fileNames = nameGenerator->GetFileNames( seriesIdentifier );

	reader->SetFileNames( fileNames );



	try
	  {
	  reader->Update();
	  }
	catch (itk::ExceptionObject &ex)
	  {
	  std::cout << ex << std::endl;
	  return EXIT_FAILURE;
	  }


}
  catch (itk::ExceptionObject &ex)
	{
	std::cout << ex << std::endl;
	return EXIT_FAILURE;
	}

typedef itk::DiscreteGaussianImageFilter<
				 InputImageType, OutputImageType >  FilterType;

  FilterType::Pointer filter = FilterType::New();
 filter->SetInput( reader->GetOutput() );

const double gaussianVariance = atof( argv[2] );
  const unsigned int maxKernelWidth = atoi( argv[3] );
 filter->SetVariance( gaussianVariance );
  filter->SetMaximumKernelWidth( maxKernelWidth );
  filter->Update();


  typedef unsigned char WritePixelType;
  typedef itk::Image< WritePixelType, 2 > WriteImageType;
  typedef itk::RescaleIntensityImageFilter< 
			   OutputImageType, WriteImageType > RescaleFilterType;
  RescaleFilterType::Pointer rescaler = RescaleFilterType::New();

  rescaler->SetOutputMinimum(   0 );
  rescaler->SetOutputMaximum( 255 );

  typedef itk::ImageFileWriter< WriteImageType >  WriterType;
  WriterType::Pointer writer = WriterType::New();
  writer->SetFileName( argv[2] );
  rescaler->SetInput( filter->GetOutput() );
  writer->SetInput( rescaler->GetOutput() );
  writer->Update();
  return EXIT_SUCCESS;

}

best regards

BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:10:25 PM

Posted 05 August 2009 - 08:03 AM

can some one help me [...] correct it


Impossible since we can't guess what the error messages are.

When asking a question about a program we need actual information like any error messages, what you expected the code to do, what it does, and what you have done so far to try and fix it.

#3 sassou

sassou
  • Topic Starter

  • Members
  • 9 posts
  • OFFLINE
  •  
  • Local time:05:25 AM

Posted 05 August 2009 - 10:51 AM

this code is to read a 3D dicom serie and then filtered it with gaussian discret filter. it uses the ITK software.When i try to buil the project i have those messages:

Build started: Project: serie, Configuration: Debug Win32 ------
Compiling...
serie.cxx
C:\insight\ITK\Utilities\gdcm\src\gdcmSerieHelper.h(114) : warning C4996: 'sscanf' was declared deprecated
c:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(311) : see declaration of 'sscanf'
Message: 'This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
.\serie.cxx(129) : error C2065: 'InputImageType' : undeclared identifier
.\serie.cxx(129) : error C2065: 'OutputImageType' : undeclared identifier
.\serie.cxx(131) : error C2955: 'itk::DiscreteGaussianImageFilter' : use of class template requires template argument list
C:\insight\ITK\Code\BasicFilters\itkDiscreteGaussianImageFilter.h(243) : see declaration of 'itk::DiscreteGaussianImageFilter'
.\serie.cxx(131) : error C2955: 'itk::DiscreteGaussianImageFilter' : use of class template requires template argument list
C:\insight\ITK\Code\BasicFilters\itkDiscreteGaussianImageFilter.h(243) : see declaration of 'itk::DiscreteGaussianImageFilter'
.\serie.cxx(131) : error C2514: 'itk::SmartPointer<itk::DiscreteGaussianImageFilter<TInputImage,TOutputImage>>' : class has no constructors
.\serie.cxx(132) : error C2678: binary '->' : no operator found which takes a left-hand operand of type 'itk::SmartPointer<itk::DiscreteGaussianImageFilter<TInputImage,TOutputImage>>' (or there is no acceptable conversion)
c:\insight\itk\code\common\itkSmartPointer.h(69): could be 'TObjectType *itk::SmartPointer<TObjectType>::operator ->(void) const'
while trying to match the argument list '(itk::SmartPointer<itk::DiscreteGaussianImageFilter<TInputImage,TOutputImage>>)'
.\serie.cxx(132) : error C2039: 'SetInput' : is not a member of 'itk::SmartPointer<itk::DiscreteGaussianImageFilter<TInputImage,TOutputImage>>'
.\serie.cxx(136) : error C2678: binary '->' : no operator found which takes a left-hand operand of type 'itk::SmartPointer<itk::DiscreteGaussianImageFilter<TInputImage,TOutputImage>>' (or there is no acceptable conversion)
c:\insight\itk\code\common\itkSmartPointer.h(69): could be 'TObjectType *itk::SmartPointer<TObjectType>::operator ->(void) const'
while trying to match the argument list '(itk::SmartPointer<itk::DiscreteGaussianImageFilter<TInputImage,TOutputImage>>)'
.\serie.cxx(136) : error C2039: 'SetVariance' : is not a member of 'itk::SmartPointer<itk::DiscreteGaussianImageFilter<TInputImage,TOutputImage>>'
.\serie.cxx(137) : error C2678: binary '->' : no operator found which takes a left-hand operand of type 'itk::SmartPointer<itk::DiscreteGaussianImageFilter<TInputImage,TOutputImage>>' (or there is no acceptable conversion)
c:\insight\itk\code\common\itkSmartPointer.h(69): could be 'TObjectType *itk::SmartPointer<TObjectType>::operator ->(void) const'
while trying to match the argument list '(itk::SmartPointer<itk::DiscreteGaussianImageFilter<TInputImage,TOutputImage>>)'
.\serie.cxx(137) : error C2039: 'SetMaximumKernelWidth' : is not a member of 'itk::SmartPointer<itk::DiscreteGaussianImageFilter<TInputImage,TOutputImage>>'
.\serie.cxx(138) : error C2678: binary '->' : no operator found which takes a left-hand operand of type 'itk::SmartPointer<itk::DiscreteGaussianImageFilter<TInputImage,TOutputImage>>' (or there is no acceptable conversion)
c:\insight\itk\code\common\itkSmartPointer.h(69): could be 'TObjectType *itk::SmartPointer<TObjectType>::operator ->(void) const'
while trying to match the argument list '(itk::SmartPointer<itk::DiscreteGaussianImageFilter<TInputImage,TOutputImage>>)'
.\serie.cxx(138) : error C2039: 'Update' : is not a member of 'itk::SmartPointer<itk::DiscreteGaussianImageFilter<TInputImage,TOutputImage>>'
.\serie.cxx(145) : error C2955: 'itk::RescaleIntensityImageFilter' : use of class template requires template argument list
c:\insight\itk\code\basicfilters\itkRescaleIntensityImageFilter.h(186) : see declaration of 'itk::RescaleIntensityImageFilter'
.\serie.cxx(145) : error C2955: 'itk::RescaleIntensityImageFilter' : use of class template requires template argument list
c:\insight\itk\code\basicfilters\itkRescaleIntensityImageFilter.h(186) : see declaration of 'itk::RescaleIntensityImageFilter'
.\serie.cxx(145) : error C2514: 'itk::SmartPointer<itk::RescaleIntensityImageFilter<TInputImage,TOutputImage>>' : class has no constructors
.\serie.cxx(147) : error C2678: binary '->' : no operator found which takes a left-hand operand of type 'itk::SmartPointer<itk::RescaleIntensityImageFilter<TInputImage,TOutputImage>>' (or there is no acceptable conversion)
c:\insight\itk\code\common\itkSmartPointer.h(69): could be 'TObjectType *itk::SmartPointer<TObjectType>::operator ->(void) const'
while trying to match the argument list '(itk::SmartPointer<itk::RescaleIntensityImageFilter<TInputImage,TOutputImage>>)'
.\serie.cxx(147) : error C2039: 'SetOutputMinimum' : is not a member of 'itk::SmartPointer<itk::RescaleIntensityImageFilter<TInputImage,TOutputImage>>'
.\serie.cxx(148) : error C2678: binary '->' : no operator found which takes a left-hand operand of type 'itk::SmartPointer<itk::RescaleIntensityImageFilter<TInputImage,TOutputImage>>' (or there is no acceptable conversion)
c:\insight\itk\code\common\itkSmartPointer.h(69): could be 'TObjectType *itk::SmartPointer<TObjectType>::operator ->(void) const'
while trying to match the argument list '(itk::SmartPointer<itk::RescaleIntensityImageFilter<TInputImage,TOutputImage>>)'
.\serie.cxx(148) : error C2039: 'SetOutputMaximum' : is not a member of 'itk::SmartPointer<itk::RescaleIntensityImageFilter<TInputImage,TOutputImage>>'
.\serie.cxx(153) : error C2678: binary '->' : no operator found which takes a left-hand operand of type 'itk::SmartPointer<itk::RescaleIntensityImageFilter<TInputImage,TOutputImage>>' (or there is no acceptable conversion)
c:\insight\itk\code\common\itkSmartPointer.h(69): could be 'TObjectType *itk::SmartPointer<TObjectType>::operator ->(void) const'
while trying to match the argument list '(itk::SmartPointer<itk::RescaleIntensityImageFilter<TInputImage,TOutputImage>>)'
.\serie.cxx(153) : error C2039: 'SetInput' : is not a member of 'itk::SmartPointer<itk::RescaleIntensityImageFilter<TInputImage,TOutputImage>>'
.\serie.cxx(153) : error C2678: binary '->' : no operator found which takes a left-hand operand of type 'itk::SmartPointer<itk::DiscreteGaussianImageFilter<TInputImage,TOutputImage>>' (or there is no acceptable conversion)
c:\insight\itk\code\common\itkSmartPointer.h(69): could be 'TObjectType *itk::SmartPointer<TObjectType>::operator ->(void) const'
while trying to match the argument list '(itk::SmartPointer<itk::DiscreteGaussianImageFilter<TInputImage,TOutputImage>>)'
.\serie.cxx(153) : error C2039: 'GetOutput' : is not a member of 'itk::SmartPointer<itk::DiscreteGaussianImageFilter<TInputImage,TOutputImage>>'
.\serie.cxx(154) : error C2678: binary '->' : no operator found which takes a left-hand operand of type 'itk::SmartPointer<itk::RescaleIntensityImageFilter<TInputImage,TOutputImage>>' (or there is no acceptable conversion)
c:\insight\itk\code\common\itkSmartPointer.h(69): could be 'TObjectType *itk::SmartPointer<TObjectType>::operator ->(void) const'
while trying to match the argument list '(itk::SmartPointer<itk::RescaleIntensityImageFilter<TInputImage,TOutputImage>>)'
.\serie.cxx(154) : error C2039: 'GetOutput' : is not a member of 'itk::SmartPointer<itk::RescaleIntensityImageFilter<TInputImage,TOutputImage>>'
Build log was saved at "file://c:\insight\lireseriedicom\serie.dir\Debug\BuildLog.htm"
serie - 26 error(s), 1 warning(s)
------ Skipped Build: Project: ALL_BUILD, Configuration: Debug Win32 ------
Project not selected to build for this solution configuration
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 1 skipped ==========


Can you explain me this

#4 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:10:25 PM

Posted 05 August 2009 - 11:47 AM

There are so many errors that I don't know where to start. What I would suggest is that break the application down into parts for starters. Get something that actually works, like a main class that outputs the arguments given to it. Something like the following (My C++ is pretty terrible, so this is how I have to do things when using C++):

int main( int argc, char* argv[] ){
	for (i = 0; i < sizeof(argv); i++){
		cout<<argv[i];
	}
	return 0;
}

Get that working, then worry about adding things. that way when it does break, you know that at a certain point it worked, and it is much easier to debug. Is there some specific code that you are trying to copy? Have you coded in C++ at all before?

#5 sassou

sassou
  • Topic Starter

  • Members
  • 9 posts
  • OFFLINE
  •  
  • Local time:05:25 AM

Posted 05 August 2009 - 05:43 PM

Please can you help me to correct it. i have no idea about pointers that's why i was blocked. by the way can you gives me some tutoriols about pointers , function main, how to pass arguments in running the program (debuging)
thank you

#6 sassou

sassou
  • Topic Starter

  • Members
  • 9 posts
  • OFFLINE
  •  
  • Local time:05:25 AM

Posted 06 August 2009 - 02:39 AM

Hello,

I didn't understand the code that i sent before . Please if some one comments it to me.That's why i can't correct errors by my self.
Please help me to understand the code.It's so important to me to understand it step by step.

Thank you for help
Regards

#7 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:10:25 PM

Posted 06 August 2009 - 09:20 AM

There are tons of tutorials on the Internet. I used Bing and came up with these just for starters:
http://www.cplusplus.com/doc/tutorial/
http://www.cprogramming.com/tutorial.html
http://www.cpp-home.com/

#8 sassou

sassou
  • Topic Starter

  • Members
  • 9 posts
  • OFFLINE
  •  
  • Local time:05:25 AM

Posted 08 August 2009 - 06:41 AM

thanks i will read them and then try to correct my program
otherwise i will send you what's new with me

a+




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users