Commit 9bd2d62e authored by Jerome Flesch's avatar Jerome Flesch

s/scan_border/scan_borders/g

Signed-off-by: Jerome Flesch's avatarJerome Flesch <jflesch@openpaper.work>
parent 9afb4d09
......@@ -9,7 +9,6 @@ include_directories(include)
add_library(pillowfight SHARED
src/pillowfight/_ace.c
src/pillowfight/_scanborder.c
src/pillowfight/_blackfilter.c
src/pillowfight/_blurfilter.c
src/pillowfight/_border.c
......@@ -19,6 +18,7 @@ add_library(pillowfight SHARED
src/pillowfight/_grayfilter.c
src/pillowfight/_masks.c
src/pillowfight/_noisefilter.c
src/pillowfight/_scanborders.c
src/pillowfight/_sobel.c
src/pillowfight/_version.c
src/pillowfight/util.c
......
......@@ -242,7 +242,7 @@ cropping areas.
#### Python API
```py
frame = pillowfight.find_scan_border(img_in)
frame = pillowfight.find_scan_borders(img_in)
```
......@@ -259,7 +259,7 @@ struct pf_rectangle {
struct pf_point b;
};
struct pf_rectangle pf_find_scan_border(const struct pf_bitmap *img_in);
struct pf_rectangle pf_find_scan_borders(const struct pf_bitmap *img_in);
```
......
......@@ -168,7 +168,7 @@ extern void pf_unpaper_masks(const struct pf_bitmap *in, struct pf_bitmap *out);
extern void pf_unpaper_noisefilter(const struct pf_bitmap *in, struct pf_bitmap *out);
extern struct pf_rectangle pf_find_scan_border(const struct pf_bitmap *img_in);
extern struct pf_rectangle pf_find_scan_borders(const struct pf_bitmap *img_in);
/*!
* \brief return Libpillowfight version
......
......@@ -8,7 +8,7 @@ import PIL.ImageDraw
import pillowfight
def scanborder(img_in, img_out):
def find_scan_borders(img_in, img_out):
img_in = PIL.Image.open(img_in)
img = img_in.copy()
......@@ -17,7 +17,7 @@ def scanborder(img_in, img_out):
# img = pillowfight.unpaper_blurfilter(img)
# img = pillowfight.unpaper_masks(img)
frame = pillowfight.find_scan_border(img)
frame = pillowfight.find_scan_borders(img)
draw = PIL.ImageDraw.Draw(img_in)
draw.rectangle(
......@@ -40,7 +40,7 @@ def scanborder(img_in, img_out):
def main():
scanborder(sys.argv[1], sys.argv[2])
find_scan_borders(sys.argv[1], sys.argv[2])
if __name__ == "__main__":
......
......@@ -64,7 +64,6 @@ setup(
'pillowfight._clib', [
'src/pillowfight/util.c',
'src/pillowfight/_ace.c',
'src/pillowfight/_scanborder.c',
'src/pillowfight/_blackfilter.c',
'src/pillowfight/_blurfilter.c',
'src/pillowfight/_border.c',
......@@ -75,6 +74,7 @@ setup(
'src/pillowfight/_masks.c',
'src/pillowfight/_noisefilter.c',
'src/pillowfight/_pymod.c',
'src/pillowfight/_scanborders.c',
'src/pillowfight/_sobel.c',
'src/pillowfight/_swt.c',
'src/pillowfight/_version.c',
......
......@@ -275,10 +275,10 @@ def swt(img_in, output_type=SWT_OUTPUT_BW_TEXT):
).convert("RGB")
def find_scan_border(img_in):
def find_scan_borders(img_in):
if img_in.mode != "RGBA":
img_in = img_in.convert("RGBA") # Add alpha to align on 32bits
return _clib.find_scan_border(
return _clib.find_scan_borders(
img_in.size[0],
img_in.size[1],
img_in.tobytes()
......
......@@ -8,7 +8,7 @@ static PyMethodDef clib_methods[] = {
{"compare", pycompare, METH_VARARGS, NULL},
{"gaussian", pygaussian, METH_VARARGS, NULL},
{"get_version", pyget_version, METH_NOARGS, NULL},
{"find_scan_border", pyfind_scan_border, METH_VARARGS, NULL},
{"find_scan_borders", pyfind_scan_borders, METH_VARARGS, NULL},
{"sobel", pysobel, METH_VARARGS, NULL},
{"swt", pyswt, METH_VARARGS, NULL},
{"unpaper_blackfilter", pyblackfilter, METH_VARARGS, NULL},
......
......@@ -10,7 +10,7 @@ PyObject *pygaussian(PyObject *self, PyObject* args);
PyObject *pygrayfilter(PyObject *self, PyObject* args);
PyObject *pymasks(PyObject *self, PyObject* args);
PyObject *pynoisefilter(PyObject *self, PyObject* args);
PyObject *pyfind_scan_border(PyObject *self, PyObject* args);
PyObject *pyfind_scan_borders(PyObject *self, PyObject* args);
PyObject *pysobel(PyObject *self, PyObject* args);
PyObject *pyswt(PyObject *self, PyObject* args);
PyObject *pyget_version(PyObject *self, PyObject* args);
......@@ -147,7 +147,7 @@ static struct pf_rectangle find_shape(
#ifndef NO_PYTHON
static
#endif
struct pf_rectangle pf_find_scan_border(const struct pf_bitmap *img_in)
struct pf_rectangle pf_find_scan_borders(const struct pf_bitmap *img_in)
{
struct pf_gradient_matrixes gradient;
struct pf_dbl_matrix x, y, xg, yg;
......@@ -194,7 +194,7 @@ struct pf_rectangle pf_find_scan_border(const struct pf_bitmap *img_in)
#ifndef NO_PYTHON
PyObject *pyfind_scan_border(PyObject *self, PyObject* args)
PyObject *pyfind_scan_borders(PyObject *self, PyObject* args)
{
int img_x, img_y;
Py_buffer img_in;
......@@ -212,7 +212,7 @@ PyObject *pyfind_scan_border(PyObject *self, PyObject* args)
bitmap_in = from_py_buffer(&img_in, img_x, img_y);
Py_BEGIN_ALLOW_THREADS;
frame = pf_find_scan_border(&bitmap_in);
frame = pf_find_scan_borders(&bitmap_in);
Py_END_ALLOW_THREADS;
PyBuffer_Release(&img_in);
......
......@@ -18,7 +18,7 @@ count = 0
def _find_scan_borders(img_in):
img_in = img_in.copy()
frame = pillowfight.find_scan_border(img_in)
frame = pillowfight.find_scan_borders(img_in)
draw = PIL.ImageDraw.Draw(img_in)
draw.rectangle(
......
......@@ -6,18 +6,18 @@ import PIL.ImageDraw
import pillowfight
class TestScanBorder(unittest.TestCase):
def test_scan_border_a(self):
class TestScanBorders(unittest.TestCase):
def test_scan_borders_a(self):
in_img = PIL.Image.open("tests/data/brother_mfc7360.jpeg")
frame = pillowfight.find_scan_border(in_img)
frame = pillowfight.find_scan_borders(in_img)
self.assertEqual(frame, (8, 37, 1637, 2195))
def test_scan_border_b(self):
def test_scan_borders_b(self):
in_img = PIL.Image.open("tests/data/epson_xp425.jpeg")
frame = pillowfight.find_scan_border(in_img)
frame = pillowfight.find_scan_borders(in_img)
self.assertEqual(frame, (11, 4, 2541, 3503))
def test_scan_border_c(self):
def test_scan_borders_c(self):
in_img = PIL.Image.open("tests/data/brother_ds620.jpeg")
frame = pillowfight.find_scan_border(in_img)
frame = pillowfight.find_scan_borders(in_img)
self.assertEqual(frame, (3, 3, 2507, 3527))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment