Run examples from Windows command line

Hello !I am just a beginner ,and want to know how to give command line input of images to .exe file created after building from cmake and visual studio?Like in ImageRegistration1.cxx there are six argc ,how to give input to that file?

1 Like

Welcome to ITK, Syed! :sunny:

The build examples can be called by opening a command prompt (run cmd.exe). Then, call the .exe file and pass command line arguments to the executable. You will likely need to change directories to the folder that contains the command with the cd command. The command line arguments become argc and argv to the main function.

See, for example:

https://www.wikihow.com/Open-the-Command-Prompt-in-Windows

Here is an example of invoking it:

1 Like

Thank you for your response. Here the example is attached if I am using the single image multiple times its running fine but with different images, it’s throwing the error.


And another question is for visualization of the processed image we have to use to feed that image to vtk for visualization, right?
The bigger picture is, I want to register MRI and PET images together using ITK and visualization have to use VTK and make GUI for loading images and show register image on Visual Studio GUI.
Registration methods may be geometrical base or landmark base method.
If you people give your expert opinion I would be highly thankful to you.opinion on how to pipeline this task step by step.
I have make GUI in Visual Studio using Qt.

Can you show us the error? What you have shown is not an error. It says that registration finished after 0 steps, with perfect registration. Of course - fixed and moving images are identical.

While you could go the route of writing your own visualization code, using existing image viewers such as Slicer and ITK-SNAP is much easier, faster and probably better. Just write the images to disk from your program and load them in a viewer. You could also use QuickView for basic visualization.

I am trying this example now through cmd and by changing the main function to void and enter the path in cxx file. By both ways following error is come along.


The second thing is there any example where we can do registration using landmark method b choosing landmarks and a thin plate or BSpline as an interpolator.Thanks

Clicking Abort or Ignore might give a more detailed error. And clicking Retry should take you to the source code file where the error is occurring. And we might need you input images to reproduce this issue, it would be good if you shared them.

That is too much interaction for an example. But such a module already exists in Slicer. You can also find some video tutorial such as this one. And ask for further help on Slicer forum.

Sorry, there is error while uploading the image.You can choose any .nii image.
Original image(MRA-TOF). I just use itk snap for the distorted/rotated image.
Actually, we are making a small software in which different registration algorithms can be implemented.
I have to make an intensity base and geometry base algorithm in the software using ITK and QT integration.
I have seen that 3D slicer software examples already, Thank you for referring it.
But we have to create our own implementation so any suggestion for implementing landmark-based algorithms(thin plate and BSpline) or that which is similar to 3D slicer are more than welcome.

You could upload it to a file sharing site and put the link here.


above is the link for MRA image. The rotated version of it is other sample image for registration

I tried running with this command line parameters: C:/a/BG0001.nii C:/a/BG0001rai.nii C:/a/BG0001-reg.nii C:/a/BG0001-diff.nii, and got the below output. No crash.

0 = 353.203 : [-0.08833282321382449, -3.999024545103853]
1 = 389.336 : [-0.8521561221065328, -2.1506268692589985]
2 = 365.865 : [-1.0475214995661077, -3.131357397635717]
3 = 381.967 : [-1.3769273207334993, -2.755203433172977]
4 = 367.758 : [-1.5995028515895369, -2.307475688819164]
5 = 369.015 : [-1.6766604026142007, -2.5452712151014647]
6 = 371.448 : [-1.9248932458755132, -2.5749436859524852]
7 = 373.691 : [-2.1702335422481296, -2.5269005909668714]
8 = 371.7 : [-2.386170252280349, -2.6528820866734284]
9 = 372.164 : [-2.5593000518433695, -2.4725322252837723]
10 = 378.196 : [-2.632832054792494, -2.573616568988868]
11 = 371.994 : [-2.757201501590413, -2.586156134498871]
12 = 369.884 : [-2.882188995652429, -2.5879242770546353]
13 = 371.679 : [-3.0071705891460656, -2.5857792157987594]
14 = 374.836 : [-3.1317171593755933, -2.5751419302398704]
15 = 377.015 : [-3.2566403282012786, -2.579523926423044]
16 = 372.653 : [-3.378153162209411, -2.608843393868959]
17 = 370.192 : [-3.492128453572604, -2.557514718075838]
18 = 373.235 : [-3.5708699579184358, -2.6545960009956437]
19 = 372.38 : [-3.5915545443876384, -2.595618056960623]
20 = 374.23 : [-3.652715820539057, -2.5827514995527556]
21 = 376.651 : [-3.713984601228841, -2.5950959927698607]
22 = 378.757 : [-3.7558219574214515, -2.5486644773217018]
23 = 378.539 : [-3.764793233869998, -2.5785990509596166]
24 = 377.101 : [-3.7893811592105293, -2.597886259867296]
25 = 375.596 : [-3.796865592917489, -2.584170434077861]
26 = 375.741 : [-3.8032036278043715, -2.588738198303679]
27 = 375.39 : [-3.8110117276536943, -2.5884760285247075]
28 = 375.145 : [-3.8187169850662954, -2.589766053507239]
29 = 374.866 : [-3.8265259373664944, -2.5895306385051278]
30 = 374.639 : [-3.834088503038442, -2.591490933561358]
31 = 374.365 : [-3.8411192041726254, -2.588084410728352]
32 = 374.267 : [-3.842622686389892, -2.591689730448552]
33 = 374.125 : [-3.844326147313948, -2.590734262947357]
34 = 374.106 : [-3.8459957422300155, -2.5917477470774086]
35 = 374.034 : [-3.847655939319002, -2.5907189405400333]
36 = 374.019 : [-3.8488472544448165, -2.5922666696948378]
Optimizer stop condition: RegularStepGradientDescentOptimizerv4: Step too small after 37 iterations. Current step (0.000976563) is less than minimum step (0.001).
Result =
 Translation X = -3.84885
 Translation Y = -2.59227
 Iterations    = 38
 Metric value  = 373.945

C:\Dev\ITK-2019\bin\RelWithDebInfo\ImageRegistration1.exe (process 29996) exited with code 0.

If you built ITK as dynamic (shared) libraries, make sure DLLs are in the path, or in the same folder as your executable.

Also, your input image is 3D and ImageRegistration1.cxx is a 2D example. If you want to experiment properly, pick an example which deals with 3D images.