Calibrate works?
This commit is contained in:
parent
26e34f7671
commit
cc711c6343
1104 changed files with 636510 additions and 75 deletions
|
|
@ -0,0 +1,51 @@
|
|||
import gab.opencv.*;
|
||||
|
||||
PImage src, dilated, eroded, both;
|
||||
OpenCV opencv;
|
||||
|
||||
void setup() {
|
||||
src = loadImage("pen_sketch.jpg");
|
||||
src.resize(src.width/2, 0);
|
||||
size(src.width*2, src.height*2);
|
||||
|
||||
opencv = new OpenCV(this, src);
|
||||
|
||||
// Dilate and Erode both need a binary image
|
||||
// So, we'll make it gray and threshold it.
|
||||
opencv.gray();
|
||||
opencv.threshold(100);
|
||||
// We'll also invert so that erosion eats away the lines
|
||||
// and dilation expands them (rather than vice-versa)
|
||||
opencv.invert();
|
||||
// save a snapshot to use in both operations
|
||||
src = opencv.getSnapshot();
|
||||
|
||||
// erode and save snapshot for display
|
||||
opencv.erode();
|
||||
eroded = opencv.getSnapshot();
|
||||
|
||||
// reload un-eroded image and dilate it
|
||||
opencv.loadImage(src);
|
||||
opencv.dilate();
|
||||
// save dilated version for display
|
||||
dilated = opencv.getSnapshot();
|
||||
// now erode on top of dilated version to close holes
|
||||
opencv.erode();
|
||||
both = opencv.getSnapshot();
|
||||
|
||||
noLoop();
|
||||
}
|
||||
|
||||
void draw() {
|
||||
image(src, 0, 0);
|
||||
image(eroded, src.width, 0);
|
||||
image(dilated, 0, src.height);
|
||||
image(both, src.width, src.height);
|
||||
|
||||
fill(0, 255, 0);
|
||||
text("original", 20, 20);
|
||||
text("erode", src.width + 20, 20);
|
||||
text("dilate", 20, src.height+20);
|
||||
text("dilate then erode\n(close holes)", src.width+20, src.height+20);
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 191 KiB |
BIN
lib/opencv_processing/examples/DilationAndErosion/pen_sketch.jpg
Normal file
BIN
lib/opencv_processing/examples/DilationAndErosion/pen_sketch.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 62 KiB |
Loading…
Add table
Add a link
Reference in a new issue