Exemple #1
0
		 int testView(imbxUint32 frameNumber, std::string fileName)
		{
			cout << "testView begin" << endl;
			string path = "C:\\Users\\maro\\Documents\\DicomFiles\\digest_article\\brain_001.dcm";
			cout << "frame number = " << frameNumber << endl;
			cout << "file name = " << fileName << endl;

			ptr<stream> readStream(new stream);
			readStream->openFile(fileName, std::ios::in);
			//parse content of the file
			ptr<streamReader> reader(new streamReader(readStream));
			//create dataSet structure, that contains the dicom tags defined in the file
			//Get a codec factory and let it use the right codec to create a dataset
			//from the input stream	
			ptr<dataSet> testDataSet = codecs::codecFactory::getCodecFactory()->load(reader);
			//read image
			ptr<image> firstImage = testDataSet->getImage(frameNumber);
			imbxUint32 width, height;
			firstImage->getSize(&width, &height);
			// Build the transforms chain
			ptr<transforms::transformsChain> chain(new transforms::transformsChain);
			//image should be processed by the modalityVOILUT
			ptr<transforms::transform> modVOILUT(new transforms::modalityVOILUT(testDataSet));
			chain->addTransform(modVOILUT);
			ptr<image> convertedImage(modVOILUT->allocateOutputImage(firstImage, width, height));
			//modVOILUT->runTransform(firstImage, 0, 0, width, height, convertedImage, 0, 0);
			//sometimes further processing may be required for presentation on the screen
			//voilut is used for converting pixel values
			ptr<transforms::VOILUT> myVoiLut(new transforms::VOILUT(testDataSet));
			//Apply the first VOI or LUT
			imbxUint32 lutId = myVoiLut->getVOILUTId(0);
			myVoiLut->setVOILUT(lutId);
			//prepare image for presentation
			ptr<image> presentationImage(myVoiLut->allocateOutputImage(convertedImage, width, height));
			myVoiLut->runTransform(convertedImage, 0, 0, width, height, presentationImage, 0, 0);
			//chain->addTransform(myVoiLut);

			//====================================================================================================View Test
			imbxInt32 iheight = height;
			imbxInt32 iwidth = width;

			myView myViewer(1, false);
			myViewer.setImage(convertedImage, chain);

			drawBitmap testBitmap(convertedImage, chain);
			//ptr<unsigned> bitMapMemory = NULL;
			//double * pointerToBitmap = reinterpret_cast <double*>( testBitmap.getBitmap<drawBitmapBGRA, 1 >(iheight, iwidth, (imbxInt32)0, (imbxInt32)0, iheight, iwidth, NULL));
			//myViewer.draw()
			//viev is an abstract class
			//====================================================================================================View Test

			cout << "testView end" << endl;

			return 0;
		}
inline Image<DataType> convertImageFromRGBA(Image<RGBA> const& image,
                               RGBAConverter<DataType> const& converter) {

    Image<RGBA> convertedImage(image.width(), image.height());

    // copy from one image to another through transformation
    std::transform(std::begin(image), std::end(image), std::begin(convertedImage),
                   [&converter](RGBA const& c){ return converter.fromRGBA(c); });

    return convertedImage;
}
Exemple #3
0
			 void getValuesMatrix(imbxUint32 frameNumber, std::string fileName, imbxUint32 height, imbxUint32 width, int * outputMatrix)
			 {
				 ptr<stream> readStream(new stream);
				 readStream->openFile(fileName, std::ios::in);
				 //parse content of the file
				 ptr<streamReader> reader(new streamReader(readStream));
				 //create dataSet structure, that contains the dicom tags defined in the file
				 //Get a codec factory and let it use the right codec to create a dataset
				 //from the input stream	
				 ptr<dataSet> testDataSet = codecs::codecFactory::getCodecFactory()->load(reader);
				 //read image
				 ptr<image> firstImage = testDataSet->getImage(frameNumber);   				
				 ptr<transforms::transform> modVOILUT(new transforms::modalityVOILUT(testDataSet));
				 ptr<image> convertedImage(modVOILUT->allocateOutputImage(firstImage, width, height));
				 ptr<transforms::VOILUT> myVoiLut(new transforms::VOILUT(testDataSet));
				 //Apply the first VOI or LUT
				 imbxUint32 lutId = myVoiLut->getVOILUTId(0);
				 myVoiLut->setVOILUT(lutId);
				 //prepare image for presentation
				 ptr<image> presentationImage(myVoiLut->allocateOutputImage(convertedImage, width, height));
				 myVoiLut->runTransform(convertedImage, 0, 0, width, height, presentationImage, 0, 0);
				 //============================================================================================================
				 imbxUint32 rowSize, channelPixelSize, channelNumber;
				 ptr<imebra::handlers::dataHandlerNumericBase> myHandler = presentationImage->getDataHandler(false, &rowSize, &channelNumber, &channelNumber);
				 //Retrive image's size in pizels
				 imbxUint32 sizeX, sizeY;
				 presentationImage->getSize(&sizeX, &sizeY);
				 //scan all the rows
				 imbxUint32 index(0);
				 for (imbxUint32 scanY = 0; scanY < height; ++scanY){
					 //scan all the colums
					 for (imbxUint32 scanX = 0; scanX < width; ++scanX){
						 for (imbxUint32 scanChannel = 0; scanChannel < channelNumber; ++scanChannel){
							 imbxInt32 channelValue = myHandler->getSignedLong(index++);
							 outputMatrix[scanX + scanY*height] =(int) channelValue;
						 }
					 }
				 }

			 }