mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
Add remove-lines.js example
This example use GetStructuringElement, Dilate and Erode to remove line of a music partition.
This commit is contained in:
parent
162b091f25
commit
1d126caba5
BIN
examples/files/note.png
Normal file
BIN
examples/files/note.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
27
examples/remove-lines.js
Normal file
27
examples/remove-lines.js
Normal file
@ -0,0 +1,27 @@
|
||||
var cv = require('../lib/opencv');
|
||||
|
||||
// Load the image
|
||||
cv.readImage('./files/note.png', function(err, im) {
|
||||
console.log('plop');
|
||||
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');
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user