[Insight-users] Enlarge the image

Arturo Caissut arturo_caissut at tiscali.it
Thu Mar 12 18:10:34 EDT 2009


Hi Luis,

you're right, the filter crops the image's pixel out of the bounds, but
I have to avoid that.
I need to prevent my future users to make an unwanted "cut": if they set
output image size large enough to paste the first one it's fine, if they
try to produce an image too little I have to preserve the original
image, and I think the best way to be a scaling made tryin' to avoid any
deformation.
Any hint about that?

Arturo


Luis Ibanez ha scritto:
>
> 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