justadudewhohacks / justadudewhohacks/opencv4nodejs

Mat noise artifacts being randomly produced

Open
#747 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
5.1k
Forks
826
PR merge metrics
No merged PRs in 30d

Description

# Error Message

# Auto Build - Full Error Log

# Manual Build - Environment Information

*OpenCV version* (example 3.4.1): 5.1.0

*With OpenCV-contrib?* (extra modules): no

*OS*: Windows 7 / 8 / 10? / MacOSX? / Ubuntu?: Windows 10

Generating new cv.Mat()s and adding content by various means frequently, randomly and non-deterministically adds random smatterings of noise, most often when generating smaller-sized Mats (200 x 200 for example, as opposed to 1080 x 720). I have been running into this from several methods, such as drawing in a region with `mat.drawFillPoly`, using `mat.setTo`, and some others.

The severity seems to be random, for example I will use one of these methods to draw a basic mask to use as an overlay elsewhere. I can delete this mask, regenerate it, and a differently shaped bit of noise will be added to the image. The noise seems to originate from the top downwards by varying degrees, sometimes being a few pixels, sometimes being noise covering half the image.

I have checked and simplified everything down to just passing in a few points to generate a basic mask Mat, normal dimensions, nothing complicated, and still see the effect. Any guesses as to what this could be? I have provided the output of me drawing several poly points, filling in the fill region with simple [255,255,255] values.

![(async) rgbPolyMask](https://user-images.githubusercontent.com/33768026/89311764-52ac6d80-d66e-11ea-829a-8eb0b2f392de.png)
![(async) rgbPolyMask](https://user-images.githubusercontent.com/33768026/89311927-8a1b1a00-d66e-11ea-9ef1-64a26f0770bd.png)

Edit:
To create these RGB masks (and save the mats to check) I do the following, passing in the image width, height and an array of { x, y } points:

```
export const generatePolyMask = (width, height, points) => {
let p2s = [
points.map((p) => {
return new cv.Point2(p.x, p.y);
}),
];

let maskRGB = new cv.Mat(height, width, cv.CV_8UC3, new cv.Vec3(0, 0, 0));
maskRGB.drawFillPoly(p2s, new cv.Vec3(255, 255, 255), cv.LINE_4);

cv.imwrite('/rgbPolyMask.png', maskRGB);

return maskRGB.splitChannels()[0];
};
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.