| 34 | { |
| 35 | public: |
| 36 | bool do_setup(int argc, char **argv) override |
| 37 | { |
| 38 | PPMLoader ppm; |
| 39 | |
| 40 | if (argc < 2) |
| 41 | { |
| 42 | // Print help |
| 43 | std::cout << "Usage: ./build/neon_scale[input_image.ppm]\n\n"; |
| 44 | std::cout << "No input_image provided, creating a dummy 640x480 image\n"; |
| 45 | // Create an empty grayscale 640x480 image |
| 46 | src.allocator()->init(TensorInfo(640, 480, Format::U8)); |
| 47 | } |
| 48 | else |
| 49 | { |
| 50 | ppm.open(argv[1]); |
| 51 | ppm.init_image(src, Format::U8); |
| 52 | } |
| 53 | |
| 54 | constexpr int scale_factor = 2; |
| 55 | |
| 56 | TensorInfo dst_tensor_info(src.info()->dimension(0) / scale_factor, src.info()->dimension(1) / scale_factor, |
| 57 | Format::U8); |
| 58 | |
| 59 | // Configure the destination image |
| 60 | dst.allocator()->init(dst_tensor_info); |
| 61 | |
| 62 | // Configure Scale function object: |
| 63 | scale.configure(&src, &dst, |
| 64 | ScaleKernelInfo{InterpolationPolicy::NEAREST_NEIGHBOR, BorderMode::UNDEFINED, PixelValue(), |
| 65 | SamplingPolicy::CENTER, false}); |
| 66 | |
| 67 | // Allocate all the images |
| 68 | src.allocator()->allocate(); |
| 69 | dst.allocator()->allocate(); |
| 70 | |
| 71 | // Fill the input image with the content of the PPM image if a filename was provided: |
| 72 | if (ppm.is_open()) |
| 73 | { |
| 74 | ppm.fill_image(src); |
| 75 | output_filename = std::string(argv[1]) + "_out.ppm"; |
| 76 | } |
| 77 | |
| 78 | return true; |
| 79 | } |
| 80 | void do_run() override |
| 81 | { |
| 82 | // Run the scale operation: |
nothing calls this directly
no test coverage detected