forked from peterbraden/node-opencv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove-lines.js
More file actions
30 lines (23 loc) · 735 Bytes
/
remove-lines.js
File metadata and controls
30 lines (23 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var cv = require('../lib/opencv');
// Load the image
cv.readImage('./files/note.png', function(err, im) {
if (err) {
throw err;
}
if (im.width() < 1 || im.height() < 1) {
throw new Error('Image has no size');
}
im.cvtColor('CV_BGR2GRAY');
var bw = im.adaptiveThreshold(255, 0, 0, 15, 2);
bw.bitwiseNot(bw);
var vertical = bw.clone();
var verticalsize = vertical.size()[0] / 30;
var verticalStructure = cv.imgproc.getStructuringElement(1, [1, verticalsize]);
// Apply morphology operations
vertical.erode(1, verticalStructure);
vertical.dilate(1, verticalStructure);
vertical.bitwiseNot(vertical);
vertical.gaussianBlur([3, 3]);
// Save output image
vertical.save('./tmp/note.png');
});