[Insight-users] Combine Images into one vertical

Gregoouc gregoris.liasis at st.ouc.ac.cy
Thu Sep 6 03:43:20 EDT 2012


I am using the TileImageFilter_Side_By_Side from ItkWikiexamples.

Here is the code


#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkTileImageFilter.h"

int main(int argc, char *argv[] )
{
  // Verify arguments
  if (argc < 4)
    {
    std::cerr << "Usage: " << std::endl;
    std::cerr << argv[0] << "input1 input2 output" << std::endl;
    return EXIT_FAILURE;
    }

  // Parse arguments
  std::string input1FileName = argv[1];
  std::string input2FileName = argv[2];
  std::string outputFileName = argv[3];

  // Output arguments
  std::cout << "input1FileName " << input1FileName << std::endl;
  std::cout << "input2FileName " << input2FileName << std::endl;;
  std::cout << "outputFileName " << outputFileName << std::endl;;
  
  typedef itk::Image< unsigned char, 2>   ImageType;

  // Read images
  typedef itk::ImageFileReader< ImageType > ImageReaderType ;
  ImageReaderType::Pointer reader1 = ImageReaderType::New();
  reader1->SetFileName(input1FileName);
  reader1->Update();

  ImageReaderType::Pointer reader2 = ImageReaderType::New();
  reader2->SetFileName(input2FileName);
  reader2->Update();

  // Tile the images side-by-side
  typedef itk::TileImageFilter< ImageType, ImageType > TileFilterType;

  TileFilterType::Pointer tileFilter = TileFilterType::New();

  itk::FixedArray< unsigned int, 2 > layout;
  
  
  layout[0] = 0;
  layout[1] = 0;

  tileFilter->SetLayout( layout );

  tileFilter->SetInput(0, reader1->GetOutput());
  tileFilter->SetInput(1, reader2->GetOutput());

  // Set the value of output pixels which are created by mismatched size
input images.
  // If the two images are the same height, this will not be used.
  unsigned char fillerValue = 128;
  tileFilter->SetDefaultPixelValue( fillerValue );

  tileFilter->Update();

  // Write the output image
  typedef itk::ImageFileWriter< ImageType > WriterType;
  WriterType::Pointer writer = WriterType::New();
  writer->SetInput( tileFilter->GetOutput() );
  writer->SetFileName( outputFileName );
  writer->Update();

  return EXIT_SUCCESS;
}


Dan Mueller-2 wrote:
> 
> Hi Grego,
> 
> Perhaps you could provide a minimal working example (MWE)? i.e. source
> code (and cmake files). The mailing list will then be able to assist
> you in making this code work, because as Bill mentioned this approach
> is expected to operate correctly.
> 
> Regards, Dan
> 
> On 6 September 2012 16:04, Gregoouc <gregoris.liasis at st.ouc.ac.cy> wrote:
>>
>> Yes the program crash during execution.
>>
>>
>> Dan Mueller-2 wrote:
>>>
>>> Hi Grego,
>>>
>>>>> Looks like TileImageFilter should do what you want by
>>>>> correctly setting the layout.
>>>> Thank you Robert but unfortunatelly this didnt work.
>>>
>>> Please provide some more information as to why this did not work. Did
>>> the program not compile? Did the program crash during execution? Did
>>> the output image not match your expectation?
>>>
>>> Regards, Dan
>>>
>>> On 6 September 2012 04:57, Gregoouc <gregoris.liasis at st.ouc.ac.cy>
>>> wrote:
>>>>
>>>> Thank you Robert but unfortunatelly this didnt work.
>>>>
>>>> Any other ideas?
>>>>
>>>> Thank you in advance.
>>>>
>>>> Grego
>>>>
>>>>
>>>>
>>>> Robert Tamburo-2 wrote:
>>>>>
>>>>> Looks like TileImageFilter should do what you want by correctly
>>>>> setting
>>>>> the
>>>>> layout. Try modifying this example for putting two images side by side
>>>>> http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/TileImageFilter_SideBySide
>>>>>
>>>>>
>>>>> from
>>>>>
>>>>>   layout[0] = 2;
>>>>>   layout[1] = 0;
>>>>>
>>>>>
>>>>> to
>>>>>
>>>>>   layout[0] = 0;
>>>>>   layout[1] = 2;
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Wed, Sep 5, 2012 at 10:02 AM, Gregoouc
>>>>> <gregoris.liasis at st.ouc.ac.cy>wrote:
>>>>>
>>>>>>
>>>>>> Dear all,
>>>>>>
>>>>>> Does anybody know how to combine multible images into one vertical?
>>>>>> Similar
>>>>>> with the TileImageFilter but not horizontal side by side, vertical
>>>>>> one
>>>>>> down
>>>>>> the other.
>>>>>>
>>>>>> Thank you
>>>>>>
>>>>>> Grego
>>>>>>
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://old.nabble.com/Combine-Images-into-one-vertical-tp34392491p34392491.html
>>>>>> Sent from the ITK - Users mailing list archive at Nabble.com.
>>>>>>
>>>>>> _____________________________________
>>>>>> 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.php
>>>>>>
>>>>>> 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
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> robert
>>>>>
>>>>> _____________________________________
>>>>> 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.php
>>>>>
>>>>> 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
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://old.nabble.com/Combine-Images-into-one-vertical-tp34392491p34394105.html
>>>> Sent from the ITK - Users mailing list archive at Nabble.com.
>>>>
>>>> _____________________________________
>>>> 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.php
>>>>
>>>> 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.php
>>>
>>> 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
>>>
>>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Combine-Images-into-one-vertical-tp34392491p34395973.html
>> Sent from the ITK - Users mailing list archive at Nabble.com.
>>
>> _____________________________________
>> 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.php
>>
>> 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.php
> 
> 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
> 
> 

-- 
View this message in context: http://old.nabble.com/Combine-Images-into-one-vertical-tp34392491p34396189.html
Sent from the ITK - Users mailing list archive at Nabble.com.



More information about the Insight-users mailing list