Skip to content

jakob-fyi/reversal-film-scanner-rework-processing

Repository files navigation

Reversal Film Scanner Rework Processing

A simple program to batch rework the scanned Images from my Reversal Film Scanner Project. The .NET Core Console Application renames, analyzes the orientation, cropping the the real image on the orientation result und rotates and flips the images.

Introduction

coming soon

Parts

Analyze Orientation

The idea behind the process is to check out the areas of the scanned images, where landscape and portrait are not overlaping. We analayze following areas left and right (rectagles between P1 (x1, y1) and P2 (x2, y2)):

Left: P1 (1070, 700), P2 (1670, 3200)

Right: P1 (4170, 700), P2 (4770, 3200)

These two areas have each a size of 600px x 2500px = 1.500.000.

Landscape

Portrait

In our program we read the color of each of these 3 million pixels and check if the are "black" or not. If a high amout of "black" pixels are found, the image has to be a portrait oriented image.

Color pixelColor = image.GetPixel(x, y);
int rgbSum = pixelColor.R + pixelColor.G + pixelColor.B;

Complete ("real") black would be RGB (0, 0, 0), white RGB (255, 255, 255). So we sum up all three colors (RGB) and look if they are low enough that we can talk about a "black" pixel.

// RrgbIsBlackLimit is a const int set to 45

if (rgbSum <= RrgbIsBlackLimit)
{
    blackPixel++;
}
return (double)blackPixel / totalPixel * 100.00;

Now we return the percantage of "black" pixels we found and if the percantage is higher than 95% (This could easily be set to a higher percantage limit).

if (percantageAvg > 95.00)
{
    return Orientation.PORTRAIT;
}
else
{
    return Orientation.LANDSCAPE;
}