Skip to content
← All articles
Article

RawAnalyser

Listen to the audio story

RawAnalyser: checking raw images in Python · 1:09 · AI-written script, synthetic voices

Transcript

Ava: A camera sensor hands you a raw image. Before anyone makes it pretty, someone has to ask: is it clipped to black or white anywhere?

Andrew: I never think about that step. Who checks it?

Ava: For one of Antoine's projects, a Python tool called RawAnalyser does. It detects black and white clipping, calculates gamma, and checks flatness with vignette detection, referencing Algolux.

Andrew: How do you tell it where to look?

Ava: You give it a folder and a JSON file that marks the region of interest and the gray patches. A small GUI lets you select those on a raw or TIFF file, saves them to that JSON, and keeps watching the raw folder for new files.

Andrew: So you drop new images in and it checks them.

Ava: That's the idea. There's also a script that inspects a single pixel and uses the Bayer pattern to tell you its color.

Andrew: Anything oddly specific in there?

Ava: One script converts 20 megapixel images down to 5 megapixels for the OV20880 sensor.

Andrew: Where's the code?

Ava: On GitHub under antoinebou12. The project page lists each script and the libraries it needs.

Table of contents

here

RawAnalyser

RawAnalyser is a Python tool for analyzing raw images: black and white clipping detection, gamma calculation, and flatness with vignette detection (Algolux).

Prerequisites

You need to have Python 2.7 installed and the following libraries:

  • json
  • time
  • numpy
  • scipy
  • pyqt5
  • argparse
  • argcomplete
  • watchdog
  • logging
  • colorama
  • plotly
  • matplotlib

Usage

  1. Run the RawAnalyser script:
python RawAnalyser.py <pathfolder> <pointfile> --func <clipping,gamma,vignette,histogram,noHist,basic, default all> --bl <black level, default 1024> --vignette <pathvignette>
  1. Start the GUI:
python GUI.py
  1. Check the value of the pixel and the color with the bayer pattern:
python RawPixel.pt input<file> x y  --bitdepth <8,10,16,default 16>

Scripts Description

RawAnalyser.py

Checks black and white clipping levels in a raw image. Takes a folder path and a JSON file with the region of interest and gray patches.

points.json

The JSON file specifying the region of interest. An example of its structure is as follows:

{
    "last_y": 798,
    "last_x": 1353,
    "gray_first_y": 691,
    "gray_first_x": 606,
    "first_x": 603,
    "first_y": 315,
    "gray_last_x": 1347,
    "gray_last_y": 795
}

GUI.py

A GUI script for image selection. It allows you to select the region of interest and the gray patches in a raw or TIFF file, which are then saved in a JSON file. It also constantly checks for new files in the raw folder.

RawPixel.py

A script to inspect the value of a specific pixel and determine its color using the Bayer pattern.

20MPto5MP.py

Converts 20-megapixel images to 5-megapixel images for the OV20880 sensor.

Camera

Example of camera sensor information:

Camera: OV2740
Resolution: (1088, 1928)
ImageType: BINARY16U
Sensor value: 10 bit
Bayer pattern: 'bggr'