This repository contains a C# program that uses the Azure Computer Vision API to remove backgrounds or apply foreground matting to images.
- An Azure account with an active subscription.
- A Computer Vision resource created in the Azure portal.
- Your Computer Vision API key and endpoint.
- .NET 5.0 or higher installed on your system.
- Clone this repository and navigate to its directory.
- Set the following environment variables with your Computer Vision API key and endpoint:
COMPUTER_VISION_SUBSCRIPTION_KEY
COMPUTER_VISION_ENDPOINT
- Update the
InputFolder
andOutputFolder
variables in theProgram.cs
file with the appropriate input and output folder paths on your system. - Build and run the program.
- Select the desired operation: (1) Remove Background or (2) Foreground Matting.
- The program will process all valid images in the input folder and save the results in the output folder.
Program.cs
: Contains the main program logic, user input handling, and image processing using the Azure Computer Vision API. Link API: https://centraluseuap.dev.cognitive.microsoft.com/docs/services/unified-vision-apis-public-preview-2023-02-01-preview/operations/63e6b6d9217d201194bbecbdProcessImageAsync()
: An async function that sends an image to the Azure Computer Vision API and saves the processed image to the specified output folder.IsValidImage()
: A helper function that checks if a file is a valid JPEG or PNG image using theSystem.Drawing.Image
class.
To learn more about Azure Computer Vision used in this project, please refer to the official Microsoft Learn documentation:
This project is licensed under the MIT License. See the LICENSE file for details.