[Insight-users] Cut ROI from a image by giving the mask

Xi LIANG liangxi1986317 at hotmail.com
Sat Jan 23 01:25:33 EST 2010


Dear all,

I am trying to cut a ROI from the fixed image based on the mask of ROI. Both fixed image and ROI mask are in the same format 128 X 128 X 124 as input. I can cut the image properly by using the following code (only the core part, and the whole code are attached. I have two questions here. Firstly, I just feel this is not the right way to do, there should be some function to do this. Secondly, I dont know how to get the total index number in one dimension, and I manually put the 128, 128, 124 into the code.

  for(i = 0; i < 128; i++)  {		  std::cerr << i << std::endl;	  for(j = 0; j < 128; j++)	  {		  for(k = 0; k < 124; k++)		  {			  pixelLocation[0] = i;			  pixelLocation[1] = j;			  pixelLocation[2] = k;			  inputPixelValue = fixedImage->GetPixel(pixelLocation);			  maskPixelValue = maskImage->GetPixel(pixelLocation);			  pixelValue = inputPixelValue * maskPixelValue;			  outputImage->SetPixel( pixelLocation, pixelValue);		  }	  }  } 
--------------------------------
Xi Liang

梁茜
--------------------------------


 		 	   		  
_________________________________________________________________
Windows Live: Make it easier for your friends to see what you’re up to on Facebook.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_2:092009
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100123/f60dc6cb/attachment-0001.htm>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: seg_from_mask.cxx
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100123/f60dc6cb/attachment-0001.asc>


More information about the Insight-users mailing list