[Insight-users] Fwd: Volume overlay

Sara Rolfe smrolfe at u.washington.edu
Thu Feb 10 16:00:03 EST 2011


I've implemented the iterator to substitute the labeled pixels for the  
image pixels.  However, the display still looks incorrect.  I'm  
wondering if I could have set up the iterator incorrectly?  My most  
recent code is attached.  If not, it may be a display problem and I  
will try the VTK mailing list.

Thanks,
Sara


		
	ConstIteratorType inputIt( labelImage, labelImage- 
 >GetLargestPossibleRegion() );
	IteratorType outputIt( bwImage, bwImage->GetLargestPossibleRegion() );
	
	for ( inputIt.GoToBegin(), outputIt.GoToBegin(); !inputIt.IsAtEnd(); + 
+inputIt, ++outputIt)
	{
		InputPixelType curLabel = inputIt.Get();
		if( curLabel > 0 ){
		outputIt.Set( curLabel );
		}
	}
	
On Feb 10, 2011, at 12:18 PM, Sara Rolfe wrote:

>>
>> Thanks Robert, I was hoping there might be a way to do this without  
>> iterating through the pixels, but I think you are right that this  
>> is the best way to go.
>>
>> On Feb 10, 2011, at 11:09 AM, robert tamburo wrote:
>>
>>> You could create a blank RGB image, iterate the RGB image, then  
>>> set pixels one by one. Something like:
>>>
>>> // initialize zero filled RGB image
>>> rgbImage = RGBImageType::New();
>>> RGBImageType::PixelType tempPixel;
>>> tempPixel.Fill(0);
>>> rgbImage->FillBuffer(tempPixel);
>>>
>>> RGBImageType::PixelType rgbPixel;
>>>
>>> // iterate RGB image
>>> RGBIteratorType it(rgbImage, rgbImage->GetLargestPossibleRegion())
>>> it.GoToBegin();
>>> while(!it.IsAtEnd())
>>> {
>>>   if(labelImage1->GetPixel(it.GetIndex() != 0)
>>>     {
>>>     // set labelImage1 pixels to green
>>>     rgbPixel[0] = 0; rgbPixel[1] = 255; rgbPixel[2] = 0;
>>>     rgbImage->SetPixel(it.GetIndex(), rgbPixel);
>>>     }
>>>   else if(labelImage2->GetPixel(it.GetIndex() != 0)
>>>     {
>>>     // set labelImage2 pixels to blue
>>>     rgbPixel[0] = 0; rgbPixel[1] = 0; rgbPixel[2] = 255;
>>>     rgbImage->SetPixel(it.GetIndex(), rgbPixel);
>>>     }
>>>   else
>>>     {
>>>     // copy image data for non-label pixels
>>>     rgbPixel.Fill(originalImage->GetPixel(it.GetIndex());
>>>     rgbImage->SetPixel(it.GetIndex(), rgbPixel);
>>>     }
>>> ++it;
>>> }
>>>
>>> Caveats: 1) images need to be of the same size and 2) above code  
>>> was written freehand without testing :)
>>>
>>> On Thu, Feb 10, 2011 at 1:38 PM, Sara Rolfe <smrolfe at u.washington.edu 
>>> > wrote:
>>> Hello,
>>>
>>> I'm attempting to overlay an image with color.  I've had trouble  
>>> finding documentation on this, either in ITK or VTK.  The way I'm  
>>> going about it is to scale the values of the image down and then  
>>> use the add image filter to add the labels on top.  I could then  
>>> use VTK to create a corresponding colormap.
>>>
>>> However, I'm getting stuck on something that should be very  
>>> simple.  My operations to combine the two images are failing.  I  
>>> think the problem is the SubtractConstantFromImageFilter.  I've  
>>> checked the output and it looks like the constant is not being  
>>> subtracted.  The input to this filter is an image with a value of  
>>> 0 for the background and 255 for the object.  I'd like to change  
>>> these to 0 and 1.  The pixel type is unsigned char.  I use the  
>>> following:
>>>
>>> 	SubFilterType::Pointer subFilter = SubFilterType::New();
>>> 	InputPixelType subValue = 254;
>>> 	subFilter->SetConstant(subValue);
>>> 	subFilter->SetInput( imageInverter->GetOutput() );
>>> 	subFilter->Update();
>>>
>>> But the output image is still 0 - 255.  Am I missing something  
>>> simple?
>>>
>>> Also, is there a better way to accomplish this task, or any  
>>> examples showing something similar?
>>>
>>> Thanks,
>>> Sara
>>>
>>> _____________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Kitware offers ITK Training Courses, for more information visit:
>>> http://www.kitware.com/products/protraining.html
>>>
>>> Please keep messages on-topic and check the ITK FAQ at:
>>> http://www.itk.org/Wiki/ITK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.itk.org/mailman/listinfo/insight-users
>>>
>>>
>>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110210/bfc4f61e/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: VolumeRenderOverlay.cxx
Type: application/octet-stream
Size: 9604 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110210/bfc4f61e/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110210/bfc4f61e/attachment-0001.htm>


More information about the Insight-users mailing list