This C++ applicaiton reads a greyscale PGM file and extracts the pixels that are above a user provided threshold as white pixels using Bredth first search
A Makefile is provided just run the following code snippet in the root directory (where the makefile is):
$ make
If everything works fine, you will find the excecutable target file in the build folder
To run the program simply run
$ ./build/findComp {ARGS}
You can run some predifined sample inputs using the following run commands
$ make runAllArguments
The run command above runs a the program with all aruments provided
Before |
After |
$ make runWriteOnly
The run command above only does the extraction and writes it to an output file without printing component data
$ make runPrintAllComponents
The run command above runs the program and prints out all components data in a sorted fashion
To remove all binary files run
$ make clean
Assuming your executable is called findcomp, it must support the following command line options:
-
-s <int> <int>(4-s) : Set the minimum and maximum valid component size.[min default = 3, max = image width * image height i.e. unlimited]
-
-t <int>: Set the threshold for component detection.- (default = 128, limit to [0 . . . 255])
-
-p: Print out all the component data (entries do not have to be sorted) as well as the total component number and the sizes of the smallest and largest components. -
-w <outPGMfile>: Write out all retained components (as foreground/background pixels) to a new PGM file,<outPGMfile>.
Note: <inputPGMfile> is a valid PGM image.
Made with ❤️ with good ol' vim

