A small utility that scans a folder of high‑resolution TIFF images, converts each pixel from RGBA to 8‑bit grayscale on the GPU, and writes out _gray.tiff files. Leverages CUDA for parallel pixel processing and libtiff for fast disk I/O, while C++17’s <filesystem> handles directory traversal.
tldr: gray_out folder contains result and images contain orignal images images used are from the assignment links
- Batch processing: Automatically finds all
.tif/.tifffiles in an input folder. - GPU‑accelerated: Converts RGBA to grayscale in parallel on the CUDA device.
- LibTIFF I/O: Fast, lossless reading/writing of TIFF images.
- Modern C++17: Uses
<filesystem>for clean directory traversal.
- CUDA Toolkit (10.x or newer)
- libtiff development headers and library
- A C++17‑capable host compiler (e.g.,
g++,clang++) - make, bash
On Ubuntu/Debian, you can install dependencies via
sudo apt update
sudo apt install build-essential libtiff-dev cuda-toolkit makeDirectory Structure . ├── convert_batch.cu # main batch + kernel implementation ├── convert_batch.hpp # declarations for batch functions & kernel ├── Makefile # build rules ├── run.sh # simple runner script └── images/ # (place your .tiff inputs here)
Building
From the project root, simply run:
makeThis compiles convert_batch.cu into the convert_batch executable, linking against libtiff and the CUDA runtime.
If you ever need to clean up:
make cleanRunning
You can invoke the tool directly:
./convert_batch <input_dir> <output_dir> [-t threadsPerBlock]Or use the provided run.sh wrapper:
bash run.sh <input_dir> <output_dir> [threadsPerBlock]<input_dir>: folder containing your .tif/.tiff files
<output_dir>: folder where *_gray.tiff files will be written (created if missing)
threadsPerBlock (optional): number of threads per CUDA block (default: 256)
Example
Place your aerial images in images/.
Build the project:
makeRun the batch conversion:
bash run.sh images/ gray_out/ 512Check gray_out/ for your converted _gray.tiff files.
Also i have tried following as much as c++ guidelines as possible