[Insight-users] Enlarge the image

Luis Ibanez luis.ibanez at kitware.com
Thu Mar 12 17:18:13 EDT 2009


Hi Arturo,

Setting destination index outside of the destination image,
may actually work out of the box.

Looking at the code of the itkPasteImageFilter, it seems
that the regions to be copied are first cropped to the
actual size of the images. Therefore this may work without
any modifications. (I haven't tried though...)

Please give it a try and let us know if you find any problem,

If that's the case, then you simply should first extract
the region of interest from the image to be pasted, and
then pass that region of interest to the PasteImageFilter.



     Regards,


         Luis


-------------------------
Arturo Caissut wrote:
> Dear Luis,
> 
> thank you very much, I found this very useful.
> Now I'll disturb you once again for a "specular" question: what about 
> creating a smaller image keepin' the same proportion of the original one?
> 
> I want to resize Image1 keeping proportion to avoid (for example)
> 
> destIndex[0] + Image1_MaxX > Image2_MaxX
> 
> I'm sorry for my ITK absolute ignorance. :-)-:
> 
> Thanks,
> Arturo
> 
> 
> 
> Luis Ibanez ha scritto:
> 
>>
>> Hi Arturo,
>>
>> Have you tried the itkPasteImageFilter ?
>>
>> http://www.itk.org/Insight/Doxygen/html/classitk_1_1PasteImageFilter.html
>>
>> This should do the trick.
>>
>> For example, if you have two images:
>>
>>   A) Image1 of size in pixels 512 x 512 x 200
>>
>>   B) Image2 of size in pixels 150 x 200 x 70
>>
>> you can "embed" or "paste" Image2 inside Image1, by simply
>> selecting the location in Image1 where you want the first
>> corner of Image2 to land.
>>
>> Let's say that you want to put that corner of Image2 in
>> the pixel of index (27, 29, 50) in Image1. You will then do
>>
>>   ImageType::IndexType destIndex;
>>   destIndex[0] = 27;
>>   destIndex[1] = 29;
>>   destIndex[2] = 50;
>>
>>   pasteImageFilter->SetDestinationImage( image1 );
>>   pasteImageFilter->SetSourceImage( image2 );
>>   pasteImageFilter->SetSourceRegion( image2->GetBufferedRegion() );
>>   pasteImageFilter->SetDestinationIndex( destIndex );
>>
>>   pasteImageFilter->Update();
>>
>>   ImageType::ConstPointer enlargedImage =
>>                              pasteImageFilter->GetOutput();
>>
>>
>> The "enlargedImage" should have the size of Image1, and its
>> pixels values everywhere, except in the region:
>>
>>         X index range : 27 -->  27 + 150
>>         Y index range : 29 -->  29 + 200
>>         Z index range : 50 -->  50 +  70
>>
>> where the pixel values will be those of Image2.
>>
>>
>>
>> You could, of course, do this manually by using the Iterators,
>> but then it will be harder to integrate with your code if you
>> have an existing pipeline....
>>
>>
>> Please let us know if you find any problem when running the
>> PastImageFilter.
>>
>>
>>    Thanks
>>
>>
>>
>>
>>
>>
>> ----------------------
>> Arturo Caissut wrote:
>>
>>> Hi,
>>>
>>> I'm working on a VTK/ITK pipeline, and I just need to embed a itk 3D 
>>> image inside of a larger one. I hope my question to be not as silly 
>>> as I thought, but I'd appreciate very much some hint on the 
>>> ImageRegionIterator approach you were suggesting some days ago: I'm 
>>> quite new on ITK programming, and I cannot figure out how to set the 
>>> needed offset.
>>> Could you please send me a "raw" example of such an embedding process?
>>>
>>> Thank you in advance,
>>> Arturo Caissut
>>>
>>>
>>>
>>>
>>
> 
> 


More information about the Insight-users mailing list