STE-Industries: utilities testing
|
Go to the documentation of this file.
39 "Width = %" PRIuFAST32
", Height = %" PRIuFAST32
", Size = %" PRIuFAST32
45 "Bits per pixel = %u\n";
55 "Horizontal resolution = %" PRIuFAST32
", Vertical resolution = %"
61 "Termite-Retinex correction program, version %u.%u\n\n";
66 "Usage: Graphic <Input Pathname> <Output Pathname> { <Options> }\n"
67 "where Options can be:\n";
72 "Invalid option %s\n";
83 "End of reading; elapsed time = %lu\n";
88 "Correcting the image with %u thread(s)\n";
94 "End of correction; elapsed time = %lu\n";
105 "End of writing; elapsed time = %lu\n";
159 Bitmap& CurrentBitmap) noexcept;
164 static void Usage(
void) noexcept(
false);
167 const char* OutputPathname,
188 Bitmap& CurrentBitmap) noexcept
190 register unsigned int Index;
194 Time = time(
nullptr);
195 TimeData = *gmtime(&Time);
200 static_cast<uint_fast32_t
>(TimeData.tm_sec),
201 static_cast<uint_fast32_t
>(TimeData.tm_min),
202 static_cast<uint_fast32_t
>(TimeData.tm_hour),
203 static_cast<uint_fast32_t
>(TimeData.tm_mday),
204 static_cast<uint_fast32_t
>(TimeData.tm_mon),
205 static_cast<uint_fast32_t
>(TimeData.tm_year),
206 static_cast<uint_fast32_t
>(TimeData.tm_wday),
207 static_cast<uint_fast32_t
>(TimeData.tm_yday),
208 static_cast<uint_fast32_t
>(clock()),
209 static_cast<uint_fast32_t
>(time(
nullptr)),
210 static_cast<uint_fast32_t
>(getpid()),
211 static_cast<uint_fast32_t
>(getppid()),
212 static_cast<uint_fast32_t
>(getuid()),
213 static_cast<uint_fast32_t
>(getgid()),
214 static_cast<uint_fast32_t
>(
reinterpret_cast<intptr_t
>(Seed)),
215 static_cast<uint_fast32_t
>(
reinterpret_cast<intptr_t
>(stdin)),
216 static_cast<uint_fast32_t
>(
reinterpret_cast<intptr_t
>
218 static_cast<uint_fast32_t
>(
reinterpret_cast<intptr_t
>(&Time)),
219 static_cast<uint_fast32_t
>(
reinterpret_cast<intptr_t
>
221 static_cast<uint_fast32_t
>(Parameters.Termites),
222 static_cast<uint_fast32_t
>(Parameters.Steps),
223 static_cast<uint_fast32_t
>(lrintf(Parameters.RepulsionStep *
224 static_cast<float>(UINT_FAST32_MAX))),
225 static_cast<uint_fast32_t
>(lrintf(Parameters.Alpha *
226 static_cast<float>(UINT_FAST32_MAX))),
227 static_cast<uint_fast32_t
>(lrintf(Parameters.Beta *
228 static_cast<float>(UINT_FAST32_MAX))),
229 static_cast<uint_fast32_t
>(CurrentBitmap.GetWidth()),
230 static_cast<uint_fast32_t
>(CurrentBitmap.GetHeight()),
236 Seed [0] ^= Seed [Index];
238 Seed [Index] ^= Seed [0] ^ Index;
239 CurrentBitmap.Randomize(Seed);
281 CurrentBitmap.GetHeight(), CurrentBitmap.GetSize()) < 0)
284 CurrentBitmap.GetBitsPerPixel()) < 0)
289 CurrentBitmap.GetHeight())) < 0)
292 CurrentBitmap.GetHorizontalResolution(),
293 CurrentBitmap.GetVerticalResolution()) < 0)
296 if (fclose(OutputFile) != 0)
317 static void Usage(
void) noexcept(
false)
319 register unsigned int Index;
435 void Application(
const char* InputPathName,
const char* OutputPathName,
442 StartTime = time(
nullptr);
446 SourceBitmap.
ReadFile(InputPathName);
448 static_cast<unsigned long>(time(
nullptr) - StartTime)) < 0)
451 if (not Parameters.Quiet)
456 if (Parameters.RandomizeFlag)
458 CorrectedBitmap = SourceBitmap.
Correct(Parameters);
460 static_cast<unsigned long>(time(
nullptr) - StartTime)) < 0)
466 CorrectedBitmap.
WriteFile(OutputPathName);
468 static_cast<unsigned long>(time(
nullptr) - StartTime)) < 0)
493 int main(
int argc,
char* argv [])
495 register unsigned int Index;
496 register size_t Length;
497 register const char* Pointer;
498 const char* InputPathName;
499 const char* OutputPathName;
512 InputPathName = *++argv;
513 OutputPathName = *++argv;
514 while (*++argv !=
nullptr)
516 if ((Pointer = strchr(*argv,
525 Length =
static_cast<size_t>(Pointer - *argv);
534 GetName(), Length) != 0)
537 Assign(Pointer, Parameters);
548 Application(InputPathName, OutputPathName, Parameters);
static constexpr const char * CORRECTING_MESSAGE
static constexpr const char * VERSION_FORMAT
@ INVALID_NUMBER_OF_TERMITES
Invalid number of termites parameter.
static constexpr unsigned int HEADER_SIZE
static constexpr unsigned int NUMBER_OF_GENERATORS
virtual void Write(FILE *OutputFile) const noexcept PURE_VIRTUAL
@ INVALID_RANDOMIZE_PARAMETER
Invalid Randomize parameter.
static constexpr const char * USAGE_FORMAT
static void WriteProperties(const Bitmap &CurrentBitmap, const char *Path) noexcept(false)
static constexpr const char * END_READING_FORMAT
#define NumberOfElements(Array)
@ MAXIMUM
The step with maximum probability is chosen.
static constexpr const char * READING_FORMAT
Bitmap Correct(register const CorrectionParameters &Parameters) noexcept(false)
static constexpr const char * FILE_SIZE_FORMAT
static constexpr const char * END_WRITING_FORMAT
@ INVALID_PATH_CHOICE_PARAMETER
Invalid Pathchoice parameter.
@ INVALID_TRUNCATE_PATH_PARAMETER
Invalid TruncatePath parameter.
void WriteFile(const char *Path) noexcept(false)
@ INVALID_NUMBER_OF_STEPS
Invalid number of steps parameter.
@ INVALID_REPULSION_STEP
Invalid repulsion step parameter.
int main(int argc, char *argv[])
static constexpr unsigned int MAXIMUM_NUMBER_OF_THREADS
void ReadFile(const char *Path) noexcept(false)
static constexpr unsigned int MAJOR_VERSION_NUMBER
static constexpr const char * RESOLUTION_FORMAT
static constexpr unsigned int MAXIMUM_NUMBER_OF_STEPS
static constexpr const char * BITS_PER_PIXEL_FORMAT
static constexpr unsigned int DIB_HEADER_SIZE
static constexpr const char * INVALID_OPTION_FORMAT
static void Initialize(void) noexcept(false)
static constexpr const char * STANDARD_OUTPUT
static void Randomize(const Bitmap::CorrectionParameters &Parameters, Bitmap &CurrentBitmap) noexcept
static constexpr const char *const OpenWriteText
static void Application(const char *InputPathname, const char *OutputPathname, const Bitmap::CorrectionParameters &Parameters) noexcept(false)
static const Bitmap::CorrectionParameters DefaultParameters
static void Finalize(void) noexcept
const ParameterDescriptor *const DescriptorTable[]
static constexpr char EQUAL_CHARACTER
static constexpr unsigned int MINOR_VERSION_NUMBER
static constexpr const char * END_CORRECTION_FORMAT
static constexpr unsigned int MAXIMUM_NUMBER_OF_TERMITES
static void Usage(void) noexcept(false)
static constexpr const char * IMAGE_SIZE_FORMAT
static constexpr const char * WRITING_FORMAT
@ INVALID_QUIET_PARAMETER
Invalid Quiet parameter.
#define IgnoreValue(Expression)
@ INVALID_NUMBER_OF_THREADS
Invalid number of threads parameter.