# Simple image registration

**URL:** https://discourse.itk.org/t/simple-image-registration/615
**Category:** Beginner Questions
**Created:** [January 23, 2018, 1:44pm UTC](https://discourse.itk.org/t/simple-image-registration/615 "2018-01-23T13:44:18Z")
**Posts on this page:** 19
**Page:** 2

<div class="post-metadata">

### Author: ![ankita](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/91b2a8/32.png) [@ankita](https://discourse.itk.org/u/ankita)
#### Post date: [March 17, 2018, 3:05pm UTC](https://discourse.itk.org/t/simple-image-registration/615/23 "2018-03-17T15:05:51Z")

</div>

Sir, I want to know whether it is possible to register our own image rather than dicom images by changing the names of images in RegistrationITKv4 program. If it is possible then what properties does a image need (like.jpg format etc)?

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [March 17, 2018, 11:05pm UTC](https://discourse.itk.org/t/simple-image-registration/615/24 "2018-03-17T23:05:51Z")

</div>

Since DICOM is handled specially, you need to pick another example which takes ordinary images. Ordinary images can be .png, .bmp etc. See list of [supported formats](https://itk.org/Wiki/ITK/File_Formats).

---

<div class="post-metadata">

### Author: ![ankita](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/91b2a8/32.png) [@ankita](https://discourse.itk.org/u/ankita)
#### Post date: [March 18, 2018, 4:00pm UTC](https://discourse.itk.org/t/simple-image-registration/615/25 "2018-03-18T16:00:18Z")

</div>

Sir, what changes should I make in program to execute it successfully? Do I need to edit my image name in place of moved image and fixed image or anything else to be done for execution.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [March 19, 2018, 2:56pm UTC](https://discourse.itk.org/t/simple-image-registration/615/26 "2018-03-19T14:56:32Z")

</div>

You could use this [example](https://itk.org/ITKExamples/src/Registration/Common/Perform2DTranslationRegistrationWithMeanSquares/Documentation.html). Input images can be in .png, .bmp, .jpg, .nnrd, .mha etc and even in one-slice DICOM format.

---

<div class="post-metadata">

### Author: ![ankita](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/91b2a8/32.png) [@ankita](https://discourse.itk.org/u/ankita)
#### Post date: [March 21, 2018, 7:27am UTC](https://discourse.itk.org/t/simple-image-registration/615/27 "2018-03-21T07:27:53Z")

</div>

Sir I am facing this error after I add moving image and fixed image in coomand promp.

 ![error](https://discourse.itk.org/uploads/default/original/1X/778939ec555f1ade91f2713543fcf34b6c364572.jpg)

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [March 21, 2018, 1:39pm UTC](https://discourse.itk.org/t/simple-image-registration/615/28 "2018-03-21T13:39:46Z")

</div>

Can you share your `bottle01.png` and `bottle02.png`?

---

<div class="post-metadata">

### Author: ![ankita](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/91b2a8/32.png) [@ankita](https://discourse.itk.org/u/ankita)
#### Post date: [March 22, 2018, 4:59am UTC](https://discourse.itk.org/t/simple-image-registration/615/29 "2018-03-22T04:59:23Z")

</div>

![bottle01](https://discourse.itk.org/uploads/default/original/1X/10da990d7cb3de38356c42da7d21d210ad8cbaf4.png) ![bottle02](https://discourse.itk.org/uploads/default/original/1X/903aaf180d6d3f9f7918b8b44afb69c04af3dff1.png)

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [March 22, 2018, 3:05pm UTC](https://discourse.itk.org/t/simple-image-registration/615/30 "2018-03-22T15:05:24Z")

</div>

On my computer it runs without crashing. Here is the after-checkerboard:  
 ![BottleAfter](https://discourse.itk.org/uploads/default/original/1X/0cb01d9958f6ae0f8805a0ea21252a011ff0e5a4.jpg)  
Here are my command-line parameters: `C:/Bottle01.png C:/Bottle02.png C:/BottleReg.png C:/BottleBefore.png C:/BottleAfter.png`. But this is a horrible registration.

Since the image also includes rotation (and perhaps some scaling?) you should try using 2D rigid or [2D similarity](https://itk.org/Doxygen/html/classitk_1_1Similarity2DTransform.html) transform instead of 2D translation transform. Example ImageRegistration7.cxx already uses similarity, while ImageRegistration5.cxx and ImageRegistration6.cxx use rigid. On [this page](https://itk.org/Wiki/ITK/Examples/Included/Registration) you can find more information about included examples. Here is the registered output of ImageRegistration7:  
 ![BottleReg](https://discourse.itk.org/uploads/default/original/1X/3535933af9da8b3d105e24f589e4fee1a7b4bfbe.jpg)

**Edit** Here is the final output of ImageRegistration7:

```auto
498 708.652 [1.0335462012447618, 0.39856625992491423, 190.80755526644373, 233.46134165434157, -0.4572761665491416, 17.556286207548332]
499 711.099 [1.03355770147716, 0.4015412995014569, 190.8074655588225, 233.46228544143096, -0.4549818569254195, 17.556781342023257]
Optimizer stop condition: RegularStepGradientDescentOptimizerv4: Maximum number of iterations (500) exceeded.

Result =
 Scale = 1.03356
 Angle (radians) 0.401541
 Angle (degrees) 23.0066
 Center X = 190.807
 Center Y = 233.462
 Translation X = -0.454982
 Translation Y = 17.5568
 Iterations = 500
 Metric value = 711.099
Press any key to continue . . .

```

---

<div class="post-metadata">

### Author: ![ankita](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/91b2a8/32.png) [@ankita](https://discourse.itk.org/u/ankita)
#### Post date: [April 2, 2018, 9:49am UTC](https://discourse.itk.org/t/simple-image-registration/615/31 "2018-04-02T09:49:46Z")

</div>

Sir I want to overlap 2 images of bottle01.png and bottle02.png and find out what changes has been occured in it. So how can I do this using ITK software.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [April 2, 2018, 1:36pm UTC](https://discourse.itk.org/t/simple-image-registration/615/32 "2018-04-02T13:36:52Z")

</div>

After registration just subtracting the images will give you a difference image, which is easy. But then interpreting that difference image is the hard part. And what kind of changes are you trying to detect? “bottle has moved 7 cm to the right”, “bottle cap missing”, “no bottle in the image”, “amount of liquid in the bottle has decreased 7%”. These are all very different things, most of them very hard to do, and all of them requiring at least somewhat different approaches.

---

<div class="post-metadata">

### Author: ![ankita](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/91b2a8/32.png) [@ankita](https://discourse.itk.org/u/ankita)
#### Post date: [April 2, 2018, 3:42pm UTC](https://discourse.itk.org/t/simple-image-registration/615/33 "2018-04-02T15:42:21Z")

</div>

Yes sir I am trying to find these changes. What are the steps to do so?

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [April 2, 2018, 3:53pm UTC](https://discourse.itk.org/t/simple-image-registration/615/34 "2018-04-02T15:53:58Z")

</div>

That is what I am trying to tell you: that problem has not been solved yet so I don’t know the steps.

---

<div class="post-metadata">

### Author: ![ankita](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/91b2a8/32.png) [@ankita](https://discourse.itk.org/u/ankita)
#### Post date: [April 2, 2018, 4:00pm UTC](https://discourse.itk.org/t/simple-image-registration/615/35 "2018-04-02T16:00:08Z")

</div>

Okay sir but how to subtract an image and see the difference?

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [April 2, 2018, 4:04pm UTC](https://discourse.itk.org/t/simple-image-registration/615/36 "2018-04-02T16:04:51Z")

</div>

`ImageRegistration7.cxx` already calculates the difference image and writes it to disk if enough filenames are given.

---

<div class="post-metadata">

### Author: ![ankita](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/91b2a8/32.png) [@ankita](https://discourse.itk.org/u/ankita)
#### Post date: [April 5, 2018, 6:07am UTC](https://discourse.itk.org/t/simple-image-registration/615/37 "2018-04-05T06:07:27Z")

</div>

sir to find out the difference in image from ImageRegistration7.cxx, we need to enter steplength initialscaling initialangle. What values should I enter in it??

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [April 5, 2018, 1:39pm UTC](https://discourse.itk.org/t/simple-image-registration/615/38 "2018-04-05T13:39:10Z")

</div>

Those three parameters are optional. Just don’t put them on the command line, the file names are enough. Their default values are good enough.

---

<div class="post-metadata">

### Author: ![ankita](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/91b2a8/32.png) [@ankita](https://discourse.itk.org/u/ankita)
#### Post date: [April 12, 2018, 9:30am UTC](https://discourse.itk.org/t/simple-image-registration/615/39 "2018-04-12T09:30:53Z")

</div>

Sir I want to make GUI-interface software. In which I have to include all the libraries of ITK. I have to make 2buttons of input images and after running it should automatically register as we see it in ITk software. Sir will you please help me in this.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [April 12, 2018, 2:53pm UTC](https://discourse.itk.org/t/simple-image-registration/615/40 "2018-04-12T14:53:40Z")

</div>

How about starting from an existing example? Quick Google search gives [this](http://qtitkvtkhelp.blogspot.com/2013/07/itk-reader-vtk-viewer-qt-gui.html), [this](https://github.com/coconetlero/Qt-ITK-VTK-Image-Viewer), [this](https://na-mic.org/w/images/e/ed/Insight-VTK.ppt) and [this](http://en.pudn.com/Download/item/id/2861803.html).

---

<div class="post-metadata">

### Author: ![ibr](https://discourse.itk.org/user_avatar/discourse.itk.org/ibr/32/468_2.png) [@ibr](https://discourse.itk.org/u/ibr)
#### Post date: [October 8, 2018, 1:52pm UTC](https://discourse.itk.org/t/simple-image-registration/615/41 "2018-10-08T13:52:12Z")

</div>

I would use Slicer is it is very simple to create a plugin that takes the input, process it using itk e.g. calling the binaries from python then load and visualize the output.

If you want a stand alone, here is a more [recent example](https://sites.google.com/site/ibraheemtutorials/classroom-news/itkexamples) that combines QT, VTK and ITK.

[Previous page](https://discourse.itk.org/t/simple-image-registration/615.md?page=1)
