mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
Open Source Bridge Live coding - woohoo
This commit is contained in:
parent
ca87972037
commit
45846cd3b2
@ -21,7 +21,7 @@ cv.readImage("/Users/peterbraden/Downloads/orl_faces/s6/10.pgm", function(e, im)
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
cv.readImage("/Users/peterbraden/Desktop/repos/node-opencv/examples/mona.png", function(e, mat){
|
cv.readImage("/Users/peterbraden/Desktop/repos/node-opencv/examples/mona.png", function(e, mat){
|
||||||
var th = mat.threshold(20, 200);
|
var th = mat.threshold(200, 200, "Threshold to Zero Inverted");
|
||||||
th.save('out.png')
|
th.save('out.png')
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1009,11 +1009,34 @@ Matrix::Threshold(const v8::Arguments& args) {
|
|||||||
double threshold = args[0]->NumberValue();
|
double threshold = args[0]->NumberValue();
|
||||||
double maxVal = args[1]->NumberValue();
|
double maxVal = args[1]->NumberValue();
|
||||||
|
|
||||||
|
int typ = cv::THRESH_BINARY;
|
||||||
|
if (args.Length() == 3){
|
||||||
|
// typ = args[2]->IntegerValue();
|
||||||
|
String::AsciiValue typstr(args[2]);
|
||||||
|
if (strcmp(*typstr, "Binary") == 0){
|
||||||
|
typ=0;
|
||||||
|
}
|
||||||
|
if (strcmp(*typstr, "Binary Inverted") == 0){
|
||||||
|
typ=1;
|
||||||
|
}
|
||||||
|
if (strcmp(*typstr, "Threshold Truncated") == 0){
|
||||||
|
typ=2;
|
||||||
|
}
|
||||||
|
if (strcmp(*typstr, "Threshold to Zero") == 0){
|
||||||
|
typ=3;
|
||||||
|
}
|
||||||
|
if (strcmp(*typstr, "Threshold to Zero Inverted") == 0){
|
||||||
|
typ=4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Local<Object> img_to_return = Matrix::constructor->GetFunction()->NewInstance();
|
Local<Object> img_to_return = Matrix::constructor->GetFunction()->NewInstance();
|
||||||
Matrix *img = ObjectWrap::Unwrap<Matrix>(img_to_return);
|
Matrix *img = ObjectWrap::Unwrap<Matrix>(img_to_return);
|
||||||
self->mat.copyTo(img->mat);
|
self->mat.copyTo(img->mat);
|
||||||
|
|
||||||
cv::threshold(self->mat, img->mat, threshold, maxVal, cv::THRESH_BINARY);
|
cv::threshold(self->mat, img->mat, threshold, maxVal, typ);
|
||||||
|
|
||||||
return scope.Close(img_to_return);
|
return scope.Close(img_to_return);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user