MCPcopy Create free account
hub / github.com/awawa-dev/HyperHDR / process

Method process

sources/blackborder/BlackBorderDetector.cpp:39–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39BlackBorder BlackBorderDetector::process(const Image<ColorRgb>& image) const
40{
41 // test centre and 33%, 66% of width/height
42 // 33 and 66 will check left and top
43 // centre will check right and bottom sides
44 int width = image.width();
45 int height = image.height();
46 int width33percent = width / 3;
47 int height33percent = height / 3;
48 int width66percent = width33percent * 2;
49 int height66percent = height33percent * 2;
50 int xCenter = width / 2;
51 int yCenter = height / 2;
52
53
54 int firstNonBlackXPixelIndex = -1;
55 int firstNonBlackYPixelIndex = -1;
56
57 width--; // remove 1 pixel to get end pixel index
58 height--;
59
60 // find first X pixel of the image
61 for (int x = 0; x < width33percent; ++x)
62 {
63 if (!isBlack(image((width - x), yCenter))
64 || !isBlack(image(x, height33percent))
65 || !isBlack(image(x, height66percent)))
66 {
67 firstNonBlackXPixelIndex = x;
68 break;
69 }
70 }
71
72 // find first Y pixel of the image
73 for (int y = 0; y < height33percent; ++y)
74 {
75 if (!isBlack(image(xCenter, (height - y)))
76 || !isBlack(image(width33percent, y))
77 || !isBlack(image(width66percent, y)))
78 {
79 firstNonBlackYPixelIndex = y;
80 break;
81 }
82 }
83
84 // Construct result
85 BlackBorder detectedBorder{};
86
87 detectedBorder.unknown = firstNonBlackXPixelIndex == -1 || firstNonBlackYPixelIndex == -1;
88 detectedBorder.horizontalSize = firstNonBlackYPixelIndex;
89 detectedBorder.verticalSize = firstNonBlackXPixelIndex;
90
91 return detectedBorder;
92}
93
94
95///

Callers 1

verifyBorderMethod · 0.45

Calls 2

widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected