Image Anonymization API: How can I implement it? What Can I Do with It?

Discover the benefits of using a REST API for image anonymization and learn how Celantur’s Cloud API can streamline your development process.


01 June 2023, by Mario Sabatino RiontinoAsk a question


As a developer seeking to seamlessly integrate image anonymization into your software or workflow, leveraging an API-based solution can bring numerous benefits.

In this article, we will explore the advantages of using Celantur Cloud API to effectively integrate image anonymization in your workflow with Rest API calls.

What You Can Do with Celantur's API

With Celantur Cloud API, users can leverage a powerful set of features for image anonymization and integration within their applications. Here's a summary of what you can achieve with Celantur Cloud API:

  • Anonymization Methods: It offers various methods to anonymize objects within images, including blur, pixelation, and blackening. You can choose the method that best suits your requirements and privacy needs.
  • Object Anonymization: It supports the anonymization of different objects such as faces, license plates, persons, and vehicles. Whether you need to protect personal information or sensitive data, Celantur Cloud API provides efficient anonymization techniques for each object type.
  • Seamless Integration: It is designed to seamlessly integrate with your existing applications. With comprehensive documentation and sample codes, integrating the API into your workflow is straightforward and efficient, ensuring a smooth and hassle-free experience.
  • Metadata and Segmentation Masks: By utilizing metadata (containing coordinates of detected objects, labels, and confidence scores) and segmentation masks, Celantur Cloud API enables you to perform quality checks on the anonymized images and extract useful information for further image processing.
  • Webhooks: It offers webhook functionality, allowing your application to receive real-time notifications when a file has been processed. This enables you to automate workflows, trigger subsequent actions, and enhance the overall efficiency of your image anonymization process.

Figure 1: Celantur Cloud API Diagram
Figure 1: Celantur Cloud API Diagram

Anonymize an Image with the API

Start by creating a new account by logging in to app.celantur.com. With your credentials, you will be able to receive the authentication token with POST https://api.celantur.com/v1/signin and interact with the API endpoints. Here you can find the complete list of Celantur’s API Endpoints and some code examples for a complete end-to-end API call.

Once authenticated, you can use the API. The Celantur Anonymization API is asynchronous because the media you send to the API may take some time to be processed, depending on the image resolution and other factors. Usually, it takes a few seconds for images.

import requests

def main():    
  credentials = {'username': 'xxx', 'password': 'xxx'}
  response = requests.post('https://api.celantur.com/v1/signin/', json=credentials, headers={'Content-Type':'application/json'})
  auth_token = response.json()['AuthenticationResult']['AccessToken']

  with open('image.jpg','rb') as f:
    image = f.read()

    response = requests.post('https://api.celantur.com/v1/file?method=blur&face=True&name=test.jpg', 
      data=image, 
      headers={'Authorization': auth_token}
    )
    file_id = response.json()['file_id']

    # query https://api.celantur.com/v1/file/{file_id}/status until status response is "done"

    image_get_response = requests.get('https://api.celantur.com/v1/file/' + file_id + '/anonymized', 
      headers={'Authorization': auth_token}
    )
    
    with open('result.jpg', 'wb') as f:
      f.write(image_get_response.content)
  
if __name__ == "__main__":
    main()

Extract Instance and Segmentation Masks

Celantur Cloud API provides additional endpoints to extract image binary segmentation masks and instance segmentation masks for processed files. The binary segmentation mask consists of two colors - The background is black, anonymized segments are white. Instead, the instance segmentation mask consists of multiple colors. The RGB color values are used to differentiate individual instances/objects.

By making a GET request to https://api.celantur.com/v1/file/{id}/binary-mask, you can obtain the binary segmentation mask for a specific file. This mask highlights the regions of the image that have been anonymized or masked.

Similarly, by making a GET request to https://api.celantur.com/v1/file/{id}/instance-mask, you can retrieve the instance segmentation mask, which provides a detailed mask for each individual instance within the image.

Figure 2: Anonymization, binary segmentation and instance segmentation applied to an image with Celantur software
Figure 2: Anonymization, binary segmentation and instance segmentation applied to an image with Celantur software

Get Metadata

In addition to image anonymization, Celantur Cloud API also offers a convenient way to retrieve metadata associated with processed files.

By making a GET https://api.celantur.com/v1/file/{id}/metadata request, you can obtain valuable information about a specific file in JSON format. It contains coordinates of detected objects, labels, confidence scores, and much more.

This metadata can be invaluable for further analysis or integration into your applications.

Webhooks

Celantur's webhook functionality allows users to receive real-time notifications when a file has been anonymized.

Customize Blurring

Celantur blurring can be customized to make anonymization visually more appealing. There are two sets of parameters that the user can tweak to customize the visual appearance of blurring:

The default settings of these parameters were carefully selected to maximize the quality of anonymization at the expense of visual appearance. However, changing such parameters might be useful in specific situations (e.g., when anonymized data is publicly available).

You can control and modify these two parameters with Celantur Cloud API endpoints.

Irreversibility of the Anonymization

The blurring algorithm employed by Celantur software, utilizing a median blur filter with a large kernel size by default, ensures that the anonymization cannot be reversed using current technology. This approach guarantees that personal and sensitive information remains protected.

In addition, for maximum loss of information, an alternative option is available where a solid black color is applied instead of blurring, further enhancing the irreversibility of the anonymization process. You can enable this with Celantur Cloud API by simply changing the method parameter.

Conclusion

  • Celantur's Image and Video Anonymization API provides a reliable solution for developers seeking to anonymize images and videos in their applications.
  • The API offers user-friendly endpoints and seamless integration with webhooks, simplifying the development process and saving valuable time and effort.
  • Celantur's Cloud API prioritizes GDPR compliance, ensuring that your data is handled with the highest standards of privacy and security.

To get started with Celantur Cloud API, you can sign up for a free account here and start testing the API for yourself.

Ask us Anything. We'll get back to you shortly

computer visiongdprdata protectionenglish
Start Demo Contact Us

Latest Blog Posts

Using object tracking to combat flickering detections in videos

How to decrease the amount of flickering detections in videos with object tracking.


How to copy XMP metadata between JPEG images (again)

Copying XMP metadata between images isn't straightforward. Read how it's done correctly.


20x Faster Than NumPy: Mean & Std for uint8 Arrays

How to calculate mean and standard deviation 20 times faster than NumPy for uint8 arrays.