Advertisement
Tark_Wight

Untitled

Apr 2nd, 2023
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. void processImage(const char* inputFilename, const char* outputFilename, float sigma)
  2. {
  3. // Load the input image
  4. std::vector<unsigned char> image;
  5. unsigned int width, height;
  6. unsigned error = lodepng::decode(image, width, height, inputFilename);
  7. if (error)
  8. {
  9. std::cerr << "Error decoding PNG: " << lodepng_error_text(error) << std::endl;
  10. return;
  11. }
  12.  
  13. // Apply the Gaussian blur filter
  14. gaussianBlur(image.data(), width, height, 4, sigma);
  15.  
  16. // Save the output image
  17. error = lodepng::encode(outputFilename, image, width, height);
  18. if (error)
  19. {
  20. std::cerr << "Error encoding PNG: " << lodepng_error_text(error) << std::endl;
  21. return;
  22. }
  23.  
  24. std::cout << "Image processed successfully!" << std::endl;
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement