In the code below,'reader->SetFileName()' has an image input into it as 'argv[1]'.
My question may seem stupid, but how do i get my image file stored into that argv array?
#include "itkImageFileReader.h"
int
main(int argc, char * argv[])
{
if (argc != 2)
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0];
std::cerr << " <InputFileName>";
std::cerr << std::endl;
return EXIT_FAILURE;
}
constexpr unsigned int Dimension = 2;
using PixelType = unsigned char;
using ImageType = itk::Image<PixelType, Dimension>;
using ReaderType = itk::ImageFileReader<ImageType>;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(argv[1]);
reader->Update();
ImageType::Pointer image = reader->GetOutput();
return EXIT_SUCCESS;
}In case of any query do comment.
Answer: You don't need to store image file into argv array. argv array is used for taking command line input in your program. so you have to pass name of the image file as input file name which will be read into arg array by the compiler. so if you see your program, you are checking for argc , if it is not 2 you are showing error to the user as below:

and argv is an array command. When you run your c++ program from command line after compiling, you simply run /.a.out (which is output of the compiler) or you compile as below:
g++ main.cpp -o main.exe where output is main.exe
then run the program as below:
main.exe "c"\a.jpg"
above line will store argc =2 and argv [0] as main.exe and argv[1] would be "c:\a.jpg" which you are actually passing into reader->SetFileName(argv[1]);
In the code below,'reader->SetFileName()' has an image input into it as 'argv[1]'. My question may seem...