cleanups
This commit is contained in:
parent
411afb56f5
commit
81df98e88f
@ -1,5 +0,0 @@
|
||||
SUBDIRS = \
|
||||
vipsCC
|
||||
|
||||
EXTRA_DIST = \
|
||||
test
|
@ -1,24 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import Image, sys
|
||||
import ImageFilter
|
||||
|
||||
im = Image.open (sys.argv[1])
|
||||
|
||||
# Crop 100 pixels off all edges.
|
||||
im = im.crop ((100, 100, im.size[0] - 100, im.size[1] - 100))
|
||||
|
||||
# Shrink by 10%
|
||||
im = im.resize ((int (im.size[0] * 0.9), int (im.size[1] * 0.9)),
|
||||
Image.BILINEAR)
|
||||
|
||||
# sharpen
|
||||
filter = ImageFilter.Kernel ((3, 3),
|
||||
(-1, -1, -1,
|
||||
-1, 16, -1,
|
||||
-1, -1, -1))
|
||||
im = im.filter (filter)
|
||||
|
||||
# write back again
|
||||
im.save (sys.argv[2])
|
||||
|
@ -1,24 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import sys
|
||||
from vipsCC import *
|
||||
|
||||
im = VImage.VImage (sys.argv[1])
|
||||
|
||||
# Crop 100 pixels off all edges.
|
||||
im = im.extract_area (100, 100, im.Xsize() - 200, im.Ysize() - 200)
|
||||
|
||||
# Shrink by 10%
|
||||
im = im.affine (0.9, 0, 0, 0.9, 0, 0, 0, 0,
|
||||
int (im.Xsize() * 0.9), int (im.Ysize() * 0.9))
|
||||
|
||||
# sharpen
|
||||
mask = VMask.VIMask (3, 3, 8, 0,
|
||||
[-1, -1, -1,
|
||||
-1, 16, -1,
|
||||
-1, -1, -1])
|
||||
im = im.conv (mask)
|
||||
|
||||
# write back again
|
||||
im.write (sys.argv[2])
|
||||
|
@ -1,37 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import sys
|
||||
|
||||
from vipsCC import *
|
||||
import Image
|
||||
|
||||
# try this 1,000 times and check for leaks
|
||||
for i in range (0,1000):
|
||||
vim = VImage.VImage (sys.argv[1])
|
||||
|
||||
# do some processing in vips ... cut out a small piece of image
|
||||
vim = vim.extract_area (500, 500, 100, 100)
|
||||
|
||||
# make a PIL image
|
||||
# we use Image.frombuffer (), so PIL is using vim's memory
|
||||
# you need to be very careful not to destroy vim until you're done with pim
|
||||
# ideally you should make a proxy class that wraps this lifetime problem up
|
||||
mode = VImage.PIL_mode_from_vips (vim)
|
||||
size = (vim.Xsize (), vim.Ysize ())
|
||||
data = vim.tobuffer ()
|
||||
pim = Image.frombuffer (mode, size, data, 'raw', mode, 0, 1)
|
||||
|
||||
# rotate 12 degrees with PIL
|
||||
pim = pim.rotate (12, Image.BILINEAR, 1)
|
||||
|
||||
# back to vips again
|
||||
# PIL doesn't have a tobuffer method, so we have to use tostring to copy the
|
||||
# data out of PIL and then fromstring to copy back into VIPS
|
||||
str = pim.tostring ()
|
||||
bands, format, type = VImage.vips_from_PIL_mode (pim.mode)
|
||||
width, height = pim.size
|
||||
vim2 = VImage.VImage.fromstring (str, width, height, bands, format)
|
||||
|
||||
# finally write from vips
|
||||
vim2.write (sys.argv[2])
|
||||
|
@ -1,44 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import sys
|
||||
|
||||
# just need this for leaktesting
|
||||
import gc
|
||||
|
||||
from vipsCC import *
|
||||
|
||||
if len (sys.argv) != 3:
|
||||
print 'usage:', sys.argv[0], 'inputimage outputimage'
|
||||
print '\tcalculate photographic negative of inputimage'
|
||||
sys.exit (1)
|
||||
|
||||
try:
|
||||
a = VImage.VImage (sys.argv[1])
|
||||
b = a.invert ()
|
||||
c = b.lin ([1,2,3],[4,5,6])
|
||||
m = VMask.VIMask (3, 3, 1, 0,
|
||||
[-1, -1, -1,
|
||||
-1, 8, -1,
|
||||
-1, -1, -1])
|
||||
d = a.conv (m)
|
||||
d.write (sys.argv[2])
|
||||
except VError.VError, e:
|
||||
e.perror (sys.argv[0])
|
||||
|
||||
# we can get properties of VImage too
|
||||
print 'inputimage is', a.Xsize (), 'pixels across'
|
||||
|
||||
print 'starting shutdown ...'
|
||||
del b
|
||||
del a
|
||||
del c
|
||||
del d
|
||||
del m
|
||||
# sometimes have to do several GCs to get them all, not sure why
|
||||
for i in range(10):
|
||||
gc.collect ()
|
||||
print 'shutdown!'
|
||||
|
||||
print 'leaked IMAGEs:'
|
||||
VImage.im__print_all ()
|
||||
print 'done ... hopefully you saw no leaks'
|
@ -1,53 +0,0 @@
|
||||
# Let make substitute the value of PYTHON_INCLUDES rather than auto*
|
||||
# this makes it easier to support multiple python installs
|
||||
INCLUDES = -I${top_srcdir}/include @VIPS_CFLAGS@ @VIPS_INCLUDES@ $(PYTHON_INCLUDES)
|
||||
|
||||
# we install to a directory inside the python area, since we are a module
|
||||
vipsccdir = $(pyexecdir)/vipsCC
|
||||
|
||||
vipscc_PYTHON = VImage.py VDisplay.py VError.py VMask.py __init__.py
|
||||
|
||||
# I tried making a suffix rule for this (and defining SUFFIXES) but I couldn't
|
||||
# get it to work, how annoying
|
||||
# FIXME at some point
|
||||
#
|
||||
# need an expanded VImage.h ... SWIG's preprocessor b0rks on includes inside
|
||||
# class definitions
|
||||
vimagemodule.cxx: VImage.i
|
||||
cpp -DSWIG -E $(top_srcdir)/include/vips/VImage.h > VImage.h
|
||||
swig -python -c++ -interface $(@:.cxx=) -I$(top_srcdir)/include -o $@ $<
|
||||
|
||||
vdisplaymodule.cxx: VDisplay.i
|
||||
swig -python -c++ -interface $(@:.cxx=) -I$(top_srcdir)/include -o $@ $<
|
||||
verrormodule.cxx: VError.i
|
||||
swig -python -c++ -interface $(@:.cxx=) -I$(top_srcdir)/include -o $@ $<
|
||||
vmaskmodule.cxx: VMask.i
|
||||
swig -python -c++ -interface $(@:.cxx=) -I$(top_srcdir)/include -o $@ $<
|
||||
|
||||
vipscc_LTLIBRARIES = vimagemodule.la vdisplaymodule.la verrormodule.la vmaskmodule.la
|
||||
|
||||
# maybe there's a clever way to avoid repeating the link stuff 4 times
|
||||
# vimagemodule uses the C API as well, so it needs libvips too
|
||||
vimagemodule_la_LDFLAGS = -module -avoid-version
|
||||
vimagemodule_la_LIBADD = ../../libsrcCC/libvipsCC.la ../../libsrc/libvips.la $(VIPS_LIBS)
|
||||
nodist_vimagemodule_la_SOURCES = vimagemodule.cxx
|
||||
|
||||
vdisplaymodule_la_LDFLAGS = -module -avoid-version
|
||||
vdisplaymodule_la_LIBADD = ../../libsrcCC/libvipsCC.la $(VIPS_LIBS)
|
||||
nodist_vdisplaymodule_la_SOURCES = vdisplaymodule.cxx
|
||||
|
||||
verrormodule_la_LDFLAGS = -module -avoid-version
|
||||
verrormodule_la_LIBADD = ../../libsrcCC/libvipsCC.la $(VIPS_LIBS)
|
||||
nodist_verrormodule_la_SOURCES = verrormodule.cxx
|
||||
|
||||
vmaskmodule_la_LDFLAGS = -module -avoid-version
|
||||
vmaskmodule_la_LIBADD = ../../libsrcCC/libvipsCC.la $(VIPS_LIBS)
|
||||
nodist_vmaskmodule_la_SOURCES = vmaskmodule.cxx
|
||||
|
||||
CLEANFILES = VImage.h
|
||||
|
||||
EXTRA_DIST = \
|
||||
VImage.i VDisplay.i VError.i VMask.i __init__.py \
|
||||
vimagemodule.cxx \
|
||||
verrormodule.cxx vdisplaymodule.cxx vmaskmodule.cxx \
|
||||
VImage.py VDisplay.py VError.py VMask.py
|
@ -1,15 +0,0 @@
|
||||
/* SWIG interface file for VDisplay.
|
||||
*/
|
||||
|
||||
%module VDisplay
|
||||
%{
|
||||
#include <vips/vipscpp.h>
|
||||
%}
|
||||
|
||||
%import "VError.i"
|
||||
|
||||
/* Need to override assignment to get refcounting working.
|
||||
*/
|
||||
%rename(__assign__) *::operator=;
|
||||
|
||||
%include vips/VDisplay.h
|
@ -1,19 +0,0 @@
|
||||
/* SWIG interface file for VError.
|
||||
*/
|
||||
|
||||
%module VError
|
||||
%{
|
||||
#include <vips/vipscpp.h>
|
||||
%}
|
||||
|
||||
%include "std_except.i"
|
||||
%include "std_string.i"
|
||||
|
||||
%include vips/VError.h
|
||||
|
||||
%extend vips::VError {
|
||||
const char *__str__ () {
|
||||
return $self->what ();
|
||||
}
|
||||
}
|
||||
|
@ -1,335 +0,0 @@
|
||||
/* SWIG interface file for vipsCC7
|
||||
*
|
||||
* 5/9/07
|
||||
* - use g_option_context_set_ignore_unknown_options() so we don't fail
|
||||
* on unrecognied -args (thanks Simon)
|
||||
* 3/8/08
|
||||
* - add .tobuffer() / .frombuffer (), .tostring (), .fromstring ()
|
||||
* methods
|
||||
* - add PIL_mode_from_vips () and vips_from_PIL_mode () utility
|
||||
* functions
|
||||
*/
|
||||
|
||||
%module VImage
|
||||
|
||||
%{
|
||||
#include <vips/vipscpp.h>
|
||||
|
||||
/* We need the C API too for the args init and some of the
|
||||
* frombuffer/tobuffer stuff.
|
||||
*/
|
||||
#include <vips/vips.h>
|
||||
%}
|
||||
|
||||
/* Need to override assignment to get refcounting working.
|
||||
*/
|
||||
%rename(__assign__) vips::VImage::operator=;
|
||||
|
||||
%include "std_list.i"
|
||||
%include "std_complex.i"
|
||||
%include "std_vector.i"
|
||||
%include "std_except.i"
|
||||
%include "std_string.i"
|
||||
%include "cstring.i"
|
||||
|
||||
%import "VError.i"
|
||||
%import "VMask.i"
|
||||
%import "VDisplay.i"
|
||||
|
||||
namespace std {
|
||||
%template(IntVector) vector<int>;
|
||||
%template(DoubleVector) vector<double>;
|
||||
%template(ImageVector) vector<VImage>;
|
||||
}
|
||||
|
||||
/* To get image data to and from VImage (eg. when interfacing with PIL) we
|
||||
* need to be able to import and export Python buffer() objects. Add new
|
||||
* methods to construct from and return pointer/length pairs, then wrap them
|
||||
* ourselves with a couple of typemaps.
|
||||
*/
|
||||
|
||||
%{
|
||||
struct VBuffer {
|
||||
void *data;
|
||||
size_t size;
|
||||
};
|
||||
%}
|
||||
|
||||
%typemap (out) VBuffer {
|
||||
$result = PyBuffer_FromMemory ($1.data, $1.size);
|
||||
}
|
||||
|
||||
%typemap (in) VBuffer {
|
||||
const char *buffer;
|
||||
Py_ssize_t buffer_len;
|
||||
|
||||
if (PyObject_AsCharBuffer ($input, &buffer, &buffer_len) == -1) {
|
||||
PyErr_SetString (PyExc_TypeError,"Type error. Unable to get char pointer from buffer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$1.data = (void *) buffer;
|
||||
$1.size = buffer_len;
|
||||
}
|
||||
|
||||
/* Need the expanded VImage.h in this directory, rather than the usual
|
||||
* vips/VImage.h. SWIG b0rks on #include inside class definitions.
|
||||
*/
|
||||
%include VImage.h
|
||||
|
||||
%extend vips::VImage {
|
||||
public:
|
||||
VBuffer tobuffer () throw (VError)
|
||||
{
|
||||
VBuffer buffer;
|
||||
|
||||
buffer.data = $self->data ();
|
||||
buffer.size = (size_t) $self->Xsize () * $self->Ysize () *
|
||||
IM_IMAGE_SIZEOF_PEL ($self->image ());
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static VImage frombuffer (VBuffer buffer, int width, int height,
|
||||
int bands, TBandFmt format) throw (VError)
|
||||
{
|
||||
return VImage (buffer.data, width, height, bands, format);
|
||||
}
|
||||
|
||||
%cstring_output_allocate_size (char **buffer, int *buffer_len, im_free (*$1))
|
||||
|
||||
void tostring (char **buffer, int *buffer_len) throw (VError)
|
||||
{
|
||||
void *vips_memory;
|
||||
|
||||
/* Eval the vips image first. This may throw an exception and we want to
|
||||
* make sure we do this before we try to malloc() space for the copy.
|
||||
*/
|
||||
vips_memory = $self->data ();
|
||||
|
||||
/* We have to copy the image data to make a string that Python can
|
||||
* manage. Use frombuffer() / tobuffer () if you want to avoid the copy
|
||||
* and manage memory lifetime yourself.
|
||||
*/
|
||||
*buffer_len = (size_t) $self->Xsize () * $self->Ysize () *
|
||||
IM_IMAGE_SIZEOF_PEL ($self->image ());
|
||||
if (!(*buffer = (char *) im_malloc (NULL, *buffer_len)))
|
||||
verror ("Unable to allocate memory for image copy.");
|
||||
memcpy (*buffer, vips_memory, *buffer_len);
|
||||
}
|
||||
|
||||
static VImage fromstring (std::string buffer, int width, int height,
|
||||
int bands, TBandFmt format) throw (VError)
|
||||
{
|
||||
void *vips_memory;
|
||||
VImage result;
|
||||
|
||||
/* We have to copy the string, then add a callback to the VImage to free
|
||||
* it when we free the VImage. Use frombuffer() / tobuffer () if you want
|
||||
* to avoid the copy and manage memory lifetime yourself.
|
||||
*/
|
||||
if (!(vips_memory = im_malloc (NULL, buffer.length ())))
|
||||
verror ("Unable to allocate memory for image copy.");
|
||||
|
||||
/* We have to use .c_str () since the string may not be contiguous.
|
||||
*/
|
||||
memcpy (vips_memory, buffer.c_str (), buffer.length ());
|
||||
result = VImage (vips_memory, width, height, bands, format);
|
||||
|
||||
if (im_add_close_callback (result.image (),
|
||||
(im_callback_fn) im_free, vips_memory, NULL))
|
||||
verror ();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
%pythoncode %{
|
||||
# try to guess a PIL mode string from a VIPS image
|
||||
def PIL_mode_from_vips (vim):
|
||||
if vim.Bands () == 3 and vim.BandFmt () == VImage.FMTUCHAR:
|
||||
return 'RGB'
|
||||
elif vim.Bands () == 4 and vim.BandFmt () == VImage.FMTUCHAR and vim.Type == VImage.VImage.RGB:
|
||||
return 'RGBA'
|
||||
elif vim.Bands () == 4 and vim.BandFmt () == VImage.FMTUCHAR and vim.Type == VImage.CMYK:
|
||||
return 'CMYK'
|
||||
elif vim.Bands () == 1 and vim.BandFmt () == VImage.FMTUCHAR:
|
||||
return 'L'
|
||||
elif vim.Bands () == 1 and vim.BandFmt () == VImage.FMTINT:
|
||||
return 'I'
|
||||
elif vim.Bands () == 1 and vim.BandFmt () == VImage.FMTFLOAT:
|
||||
return 'F'
|
||||
elif vim.Bands () == 2 and vim.BandFmt () == VImage.FMTUCHAR:
|
||||
return 'LA'
|
||||
else:
|
||||
raise ValueError ('unsupported vips -> pil image')
|
||||
|
||||
# return vips (bands, format, type) for a PIL mode
|
||||
def vips_from_PIL_mode (mode):
|
||||
if mode == 'RGB':
|
||||
return (3, VImage.FMTUCHAR, VImage.RGB)
|
||||
elif mode == 'RGBA':
|
||||
return (4, VImage.FMTUCHAR, VImage.RGB)
|
||||
elif mode == 'CMYK':
|
||||
return (4, VImage.FMTUCHAR, VImage.CMYK)
|
||||
elif mode == 'L':
|
||||
return (1, VImage.FMTUCHAR, VImage.B_W)
|
||||
elif mode == 'I':
|
||||
return (1, VImage.FMTINT, VImage.B_W)
|
||||
elif mode == 'F':
|
||||
return (1, VImage.FMTFLOAT, VImage.B_W)
|
||||
elif mode == 'LA':
|
||||
return (2, VImage.FMTUCHAR, VImage.B_W)
|
||||
else:
|
||||
raise ValueError ('unsupported pil -> vips image')
|
||||
%}
|
||||
|
||||
/* Helper code for vips_init().
|
||||
*/
|
||||
%{
|
||||
/* Turn on to print args.
|
||||
#define DEBUG
|
||||
*/
|
||||
|
||||
/* Command-line args during parse.
|
||||
*/
|
||||
typedef struct _Args {
|
||||
/* The n strings we alloc when we get from Python.
|
||||
*/
|
||||
int n;
|
||||
char **str;
|
||||
|
||||
/* argc/argv as processed by us.
|
||||
*/
|
||||
int argc;
|
||||
char **argv;
|
||||
} Args;
|
||||
|
||||
#ifdef DEBUG
|
||||
static void
|
||||
args_print (Args *args)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf ("args_print: argc = %d\n", args->argc);
|
||||
// +1 so we print the trailing NULL too
|
||||
for (i = 0; i < args->argc + 1; i++)
|
||||
printf ("\t%2d)\t%s\n", i, args->argv[i]);
|
||||
}
|
||||
#endif /*DEBUG*/
|
||||
|
||||
static void
|
||||
args_free (Args *args)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < args->n; i++)
|
||||
IM_FREE (args->str[i]);
|
||||
args->n = 0;
|
||||
args->argc = 0;
|
||||
IM_FREE (args->str);
|
||||
IM_FREE (args->argv);
|
||||
IM_FREE (args);
|
||||
}
|
||||
|
||||
/* Get argv/argc from python.
|
||||
*/
|
||||
static Args *
|
||||
args_new (void)
|
||||
{
|
||||
Args *args;
|
||||
PyObject *av;
|
||||
int i;
|
||||
int n;
|
||||
|
||||
args = g_new (Args, 1);
|
||||
args->n = 0;
|
||||
args->str = NULL;
|
||||
args->argc = 0;
|
||||
args->argv = NULL;
|
||||
|
||||
if (!(av = PySys_GetObject ((char *) "argv")))
|
||||
return (args);
|
||||
if (!PyList_Check (av)) {
|
||||
PyErr_Warn (PyExc_Warning, "ignoring sys.argv: "
|
||||
"it must be a list of strings");
|
||||
return args;
|
||||
}
|
||||
|
||||
n = PyList_Size (av);
|
||||
args->str = g_new (char *, n);
|
||||
for (i = 0; i < n; i++)
|
||||
args->str[i] = g_strdup (PyString_AsString (PyList_GetItem (av, i)));
|
||||
args->n = n;
|
||||
|
||||
/* +1 for NULL termination.
|
||||
*/
|
||||
args->argc = n;
|
||||
args->argv = g_new (char *, n + 1);
|
||||
for (i = 0; i < n; i++)
|
||||
args->argv[i] = args->str[i];
|
||||
args->argv[i] = NULL;
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
static void
|
||||
vips_fatal (const char *msg)
|
||||
{
|
||||
char buf[256];
|
||||
|
||||
im_snprintf (buf, 256, "%s\n%s", msg, im_error_buffer());
|
||||
im_error_clear ();
|
||||
Py_FatalError (buf);
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%init %{
|
||||
{
|
||||
Args *args;
|
||||
|
||||
args = args_new ();
|
||||
|
||||
#ifdef DEBUG
|
||||
printf ("on startup:\n");
|
||||
args_print (args);
|
||||
#endif /*DEBUG*/
|
||||
|
||||
if (im_init_world (args->argv[0])) {
|
||||
args_free (args);
|
||||
vips_fatal ("can't initialise module vips");
|
||||
}
|
||||
|
||||
/* Now parse any GOptions.
|
||||
*/
|
||||
GError *error = NULL;
|
||||
GOptionContext *context;
|
||||
|
||||
context = g_option_context_new ("- vips");
|
||||
g_option_context_add_group (context, im_get_option_group());
|
||||
|
||||
g_option_context_set_ignore_unknown_options (context, TRUE);
|
||||
if (!g_option_context_parse (context,
|
||||
&args->argc, &args->argv, &error)) {
|
||||
g_option_context_free (context);
|
||||
args_free (args);
|
||||
im_error ("vipsmodule", "%s", error->message);
|
||||
g_error_free (error);
|
||||
vips_fatal ("can't initialise module vips");
|
||||
}
|
||||
g_option_context_free (context);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf ("after parse:\n");
|
||||
args_print (args);
|
||||
#endif /*DEBUG*/
|
||||
|
||||
// Write (possibly) modified argc/argv back again.
|
||||
if (args->argv)
|
||||
PySys_SetArgv (args->argc, args->argv);
|
||||
|
||||
args_free (args);
|
||||
}
|
||||
%}
|
||||
|
@ -1,35 +0,0 @@
|
||||
/* SWIG interface file for VMask.
|
||||
*/
|
||||
|
||||
%module VMask
|
||||
%{
|
||||
#include <stdexcept>
|
||||
#include <vips/vipscpp.h>
|
||||
%}
|
||||
|
||||
%import "VError.i"
|
||||
%import "VImage.i"
|
||||
|
||||
/* Need to override assignment to get refcounting working.
|
||||
*/
|
||||
%rename(__assign__) *::operator=;
|
||||
|
||||
/* [] is array subscript, as you'd expect.
|
||||
*/
|
||||
%rename(__index__) vips::VIMask::operator[];
|
||||
%rename(__index__) vips::VDMask::operator[];
|
||||
|
||||
/* () is 2d array subscript, how odd!
|
||||
*/
|
||||
%rename(__call__) vips::VIMask::operator();
|
||||
%rename(__call__) vips::VDMask::operator();
|
||||
|
||||
/* Type conversion operators renamed as functions.
|
||||
*/
|
||||
%rename(convert_VImage) vips::VIMask::operator vips::VImage;
|
||||
%rename(convert_VImage) vips::VDMask::operator vips::VImage;
|
||||
|
||||
%rename(convert_VIMask) vips::VDMask::operator vips::VIMask;
|
||||
%rename(convert_VDMask) vips::VIMask::operator vips::VDMask;
|
||||
|
||||
%include vips/VMask.h
|
@ -1 +0,0 @@
|
||||
__all__=["VImage","VMask","VError","VDisplay"]
|
@ -1,6 +0,0 @@
|
||||
|
||||
SUBDIRS = \
|
||||
iofuncs \
|
||||
mosaicing \
|
||||
other \
|
||||
scripts
|
@ -1,27 +0,0 @@
|
||||
bin_PROGRAMS = \
|
||||
vips \
|
||||
binfile \
|
||||
debugim \
|
||||
edvips \
|
||||
header \
|
||||
printlines
|
||||
|
||||
vips_SOURCES = vips.c
|
||||
binfile_SOURCES = binfile.c
|
||||
debugim_SOURCES = debugim.c
|
||||
edvips_SOURCES = edvips.c
|
||||
header_SOURCES = header.c
|
||||
printlines_SOURCES = printlines.c
|
||||
|
||||
INCLUDES = -I${top_srcdir}/include @VIPS_CFLAGS@ @VIPS_INCLUDES@
|
||||
AM_LDFLAGS = @LDFLAGS@
|
||||
LDADD = @VIPS_CFLAGS@ ${top_builddir}/libsrc/libvips.la @VIPS_LIBS@
|
||||
|
||||
if ENABLE_LINKS
|
||||
install-exec-hook:
|
||||
${top_srcdir}/src/scripts/post_install ${DESTDIR}${bindir}
|
||||
endif
|
||||
|
||||
uninstall-hook:
|
||||
${RM} ${bindir}/im_*
|
||||
|
@ -1,81 +0,0 @@
|
||||
/* @(#) Command which adds a vasari header to a binary file
|
||||
* @(#) The user must ensure that the size of the file is correct
|
||||
* @(#)
|
||||
* @(#) Usage: binfile infile outfile xs ys bands
|
||||
* @(#)
|
||||
*
|
||||
* Copyright: 1991, N. Dessipris.
|
||||
*
|
||||
* Author: Nicos Dessipris
|
||||
* Written on: 31/07/1991
|
||||
* Modified on:
|
||||
* 2/2/95 JC
|
||||
* - ANSIfied
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file is part of VIPS.
|
||||
|
||||
VIPS is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
#include <vips/intl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
IMAGE *bin, *out;
|
||||
int xs, ys, bands, offset;
|
||||
|
||||
if( argc != 7 )
|
||||
error_exit( "usage: %s infile outfile xsize ysize bands offset",
|
||||
argv[0] );
|
||||
|
||||
xs = atoi(argv[3]);
|
||||
ys = atoi(argv[4]);
|
||||
bands = atoi(argv[5]);
|
||||
offset = atoi(argv[6]);
|
||||
|
||||
if( im_init_world( argv[0] ) )
|
||||
error_exit( "unable to start VIPS" );
|
||||
|
||||
if( !(out = im_open( argv[2], "w" )) )
|
||||
error_exit( "unable to open %s for output", argv[2] );
|
||||
if( !(bin = im_binfile( argv[1], xs, ys, bands, offset )) )
|
||||
error_exit( "unable to im_binfile" );
|
||||
if( im_copy( bin, out ) )
|
||||
error_exit( "unable to copy to %s", argv[2] );
|
||||
|
||||
im_close( out );
|
||||
im_close( bin );
|
||||
|
||||
return( 0 );
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
/* @(#) Prints the values of a file
|
||||
* @(#) Result is printed in stderr output
|
||||
* @(#)
|
||||
* @(#) Usage: debugim infile
|
||||
* @(#)
|
||||
*
|
||||
* Copyright: 1990, N. Dessipris.
|
||||
*
|
||||
* Author: Nicos Dessipris
|
||||
* Written on: 03/08/1990
|
||||
* Modified on:
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file is part of VIPS.
|
||||
|
||||
VIPS is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
#include <vips/intl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
IMAGE *in;
|
||||
|
||||
if( argc != 2 )
|
||||
error_exit( "usage: %s infile", argv[0] );
|
||||
|
||||
if( im_init_world( argv[0] ) )
|
||||
error_exit( "unable to start VIPS" );
|
||||
|
||||
if( !(in = im_open( argv[1], "r" )) )
|
||||
error_exit( "unable to open %s for input", argv[1]);
|
||||
|
||||
if( im_debugim( in ) )
|
||||
error_exit( "unable to im_debugim");
|
||||
|
||||
im_close( in );
|
||||
|
||||
return( 0 );
|
||||
}
|
@ -1,206 +0,0 @@
|
||||
/* modify vips file header! - useful for setting resolution, coding...
|
||||
very dangerous!
|
||||
no way of setting non-used codes in variables like newxres
|
||||
so need flags to show new parameter has been set.. boring
|
||||
Copyright K.Martinez 30/6/93
|
||||
29/7/93 JC
|
||||
-format added
|
||||
- ==0 added to strcmp!
|
||||
17/11/94 JC
|
||||
- new header fields added
|
||||
21/10/04
|
||||
- more header updates
|
||||
|
||||
22/8/05
|
||||
- less-stupid-ified
|
||||
20/9/05
|
||||
- rewritten with glib option parser, ready for xml options to go in
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file is part of VIPS.
|
||||
|
||||
VIPS is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
#include <vips/intl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
#include <vips/internal.h>
|
||||
|
||||
/* We have to represent all header fields as char* so we can spot unset args
|
||||
* safely.
|
||||
*/
|
||||
static char *xsize = NULL;
|
||||
static char *ysize = NULL;
|
||||
static char *bands = NULL;
|
||||
static char *format = NULL;
|
||||
static char *type = NULL;
|
||||
static char *coding = NULL;
|
||||
static char *xres = NULL;
|
||||
static char *yres = NULL;
|
||||
static char *xoffset = NULL;
|
||||
static char *yoffset = NULL;
|
||||
static gboolean setext = FALSE;
|
||||
|
||||
static GOptionEntry entries[] = {
|
||||
{ "xsize", 'x', 0, G_OPTION_ARG_STRING, &xsize,
|
||||
N_( "set Xsize to N" ), "N" },
|
||||
{ "ysize", 'y', 0, G_OPTION_ARG_STRING, &ysize,
|
||||
N_( "set Ysize to N" ), "N" },
|
||||
{ "bands", 'b', 0, G_OPTION_ARG_STRING, &bands,
|
||||
N_( "set Bands to N" ), "N" },
|
||||
{ "format", 'f', 0, G_OPTION_ARG_STRING, &format,
|
||||
N_( "set BandFmt to F (eg. IM_BANDFMT_UCHAR)" ), "F" },
|
||||
{ "type", 't', 0, G_OPTION_ARG_STRING, &type,
|
||||
N_( "set Type to T (eg. IM_TYPE_XYZ)" ), "T" },
|
||||
{ "coding", 'c', 0, G_OPTION_ARG_STRING, &coding,
|
||||
N_( "set Coding to C (eg. IM_CODING_LABQ)" ), "C" },
|
||||
{ "xres", 'X', 0, G_OPTION_ARG_STRING, &xres,
|
||||
N_( "set Xres to R pixels/mm" ), "R" },
|
||||
{ "yres", 'Y', 0, G_OPTION_ARG_STRING, &yres,
|
||||
N_( "set Yres to R pixels/mm" ), "R" },
|
||||
{ "xoffset", 'u', 0, G_OPTION_ARG_STRING, &xoffset,
|
||||
N_( "set Xoffset to N" ), "N" },
|
||||
{ "yoffset", 'v', 0, G_OPTION_ARG_STRING, &yoffset,
|
||||
N_( "set Yoffset to N" ), "N" },
|
||||
{ "setext", 'e', 0, G_OPTION_ARG_NONE, &setext,
|
||||
N_( "replace extension block with stdin" ), NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
parse_pint( char *arg, int *out )
|
||||
{
|
||||
/* Might as well set an upper limit.
|
||||
*/
|
||||
*out = atoi( arg );
|
||||
if( *out <= 0 || *out > 1000000 )
|
||||
error_exit( _( "'%s' is not a positive integer" ), arg );
|
||||
}
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
GOptionContext *context;
|
||||
GError *error = NULL;
|
||||
IMAGE *im;
|
||||
unsigned char header[IM_SIZEOF_HEADER];
|
||||
|
||||
if( im_init_world( argv[0] ) )
|
||||
error_exit( "%s", _( "unable to start VIPS" ) );
|
||||
|
||||
context = g_option_context_new(
|
||||
_( "vipsfile - edit vipsfile header" ) );
|
||||
g_option_context_add_main_entries( context, entries, GETTEXT_PACKAGE );
|
||||
g_option_context_add_group( context, im_get_option_group() );
|
||||
if( !g_option_context_parse( context, &argc, &argv, &error ) ) {
|
||||
if( error ) {
|
||||
fprintf( stderr, "%s\n", error->message );
|
||||
g_error_free( error );
|
||||
}
|
||||
|
||||
exit( -1 );
|
||||
}
|
||||
if( argc != 2 ) {
|
||||
fprintf( stderr, _( "usage: %s [OPTION...] vipsfile\n" ),
|
||||
g_get_prgname() );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
if( !(im = im_init( argv[1] )) ||
|
||||
(im->fd = im__open_image_file( im->filename )) == -1 )
|
||||
error_exit( _( "could not open image %s" ), argv[1] );
|
||||
if( read( im->fd, header, IM_SIZEOF_HEADER ) != IM_SIZEOF_HEADER ||
|
||||
im__read_header_bytes( im, header ) )
|
||||
error_exit( _( "could not read VIPS header for %s" ),
|
||||
im->filename );
|
||||
|
||||
if( xsize )
|
||||
parse_pint( xsize, &im->Xsize );
|
||||
if( ysize )
|
||||
parse_pint( ysize, &im->Ysize );
|
||||
if( bands )
|
||||
parse_pint( bands, &im->Bands );
|
||||
if( format ) {
|
||||
if( (im->BandFmt = im_char2BandFmt( format )) < 0 )
|
||||
error_exit( _( "bad format %s" ), format );
|
||||
im->Bbits = im_bits_of_fmt( im->BandFmt );
|
||||
}
|
||||
if( type ) {
|
||||
if( (im->Type = im_char2Type( type )) < 0 )
|
||||
error_exit( _( "bad type %s" ), type );
|
||||
}
|
||||
if( coding ) {
|
||||
if( (im->Coding = im_char2Coding( coding )) < 0 )
|
||||
error_exit( _( "bad coding %s" ), coding );
|
||||
}
|
||||
if( xres )
|
||||
im->Xres = atof( xres );
|
||||
if( yres )
|
||||
im->Yres = atof( yres );
|
||||
if( xoffset )
|
||||
im->Xoffset = atoi( xoffset );
|
||||
if( yoffset )
|
||||
im->Yoffset = atoi( yoffset );
|
||||
|
||||
if( lseek( im->fd, 0, SEEK_SET ) == (off_t) -1 )
|
||||
error_exit( _( "could not seek on %s" ), im->filename );
|
||||
if( im__write_header_bytes( im, header ) ||
|
||||
im__write( im->fd, header, IM_SIZEOF_HEADER ) )
|
||||
error_exit( _( "could not write to %s" ), im->filename );
|
||||
|
||||
if( setext ) {
|
||||
char *xml;
|
||||
unsigned int size;
|
||||
|
||||
if( !(xml = im__file_read( stdin, "stdin", &size )) )
|
||||
error_exit( "%s", _( "could not get ext data" ) );
|
||||
|
||||
/* Strip trailing whitespace ... we can get stray \n at the
|
||||
* end, eg. "echo | edvips --setext fred.v".
|
||||
*/
|
||||
while( size > 0 && isspace( xml[size - 1] ) )
|
||||
size -= 1;
|
||||
|
||||
if( im__write_extension_block( im, xml, size ) )
|
||||
error_exit( "%s", _( "could not set extension" ) );
|
||||
im_free( xml );
|
||||
}
|
||||
|
||||
im_close( im );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
@ -1,201 +0,0 @@
|
||||
/* @(#) Command; reads the header of a Vasari picture file.
|
||||
* @(#) Usage: header vasari_file
|
||||
* @(#)
|
||||
*
|
||||
* Copyright: Birkbeck College, History of Art Dept, London, VASARI project.
|
||||
*
|
||||
* Author: Nicos Dessipris
|
||||
* Written on: 17/01/1990
|
||||
* Modified on : 17/04/1990, 2/6/93 K.Martinez
|
||||
* 16/6/93 JC
|
||||
* - now calls im_mmapin instead of bizzare bogosity
|
||||
* 1/6/95 JC
|
||||
* - extra field argument for testing particular bits of the header
|
||||
* 29/10/98 JC
|
||||
* - now uses im_open()
|
||||
* 24/5/01 JC
|
||||
* - uses im_tiff2vips_header() etc., for speed
|
||||
* 7/5/03 JC
|
||||
* - uses im_open_header()
|
||||
* 1/8/05
|
||||
* - uses new header API, for great smallness
|
||||
* 4/8/05
|
||||
* - back to plain im_open() now that's lazy enough for us
|
||||
* 9/9/05
|
||||
* - display meta fields in save format, if possible
|
||||
* 20/9/05
|
||||
* - new field name "getext" reads extension block
|
||||
* 24/8/06
|
||||
* - use GOption, loop over args
|
||||
* 4/1/07
|
||||
* - use im_history_get()
|
||||
* 29/2/08
|
||||
* - don't stop on error
|
||||
* 23/7/09
|
||||
* - ... but do return an error code if anything failed
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file is part of VIPS.
|
||||
|
||||
VIPS is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
#include <vips/intl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
#include <vips/internal.h>
|
||||
|
||||
static char *main_option_field = NULL;
|
||||
|
||||
static GOptionEntry main_option[] = {
|
||||
{ "field", 'f', 0, G_OPTION_ARG_STRING, &main_option_field,
|
||||
N_( "print value of FIELD (\"getext\" reads extension block, "
|
||||
"\"Hist\" reads image history)" ),
|
||||
"FIELD" },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
/* A non-fatal error. Print the vips error buffer and continue.
|
||||
*/
|
||||
static void
|
||||
print_error( const char *fmt, ... )
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start( ap, fmt );
|
||||
vfprintf( stderr, fmt, ap );
|
||||
va_end( ap );
|
||||
fprintf( stderr, "\n%s", im_error_buffer() );
|
||||
im_error_clear();
|
||||
}
|
||||
|
||||
/* Print header, or parts of header.
|
||||
*/
|
||||
static int
|
||||
print_header( IMAGE *im )
|
||||
{
|
||||
if( !main_option_field )
|
||||
im_printdesc( im );
|
||||
else if( strcmp( main_option_field, "getext" ) == 0 ) {
|
||||
if( im__has_extension_block( im ) ) {
|
||||
void *buf;
|
||||
int size;
|
||||
|
||||
if( !(buf = im__read_extension_block( im, &size )) )
|
||||
return( -1 );
|
||||
printf( "%s", (char *) buf );
|
||||
im_free( buf );
|
||||
}
|
||||
}
|
||||
else if( strcmp( main_option_field, "Hist" ) == 0 )
|
||||
printf( "%s", im_history_get( im ) );
|
||||
else {
|
||||
GValue value = { 0 };
|
||||
GType type;
|
||||
|
||||
if( im_header_get( im, main_option_field, &value ) )
|
||||
return( -1 );
|
||||
|
||||
/* Display the save form, if there is one. This way we display
|
||||
* something useful for ICC profiles, xml fields, etc.
|
||||
*/
|
||||
type = G_VALUE_TYPE( &value );
|
||||
if( g_value_type_transformable( type, IM_TYPE_SAVE_STRING ) ) {
|
||||
GValue save_value = { 0 };
|
||||
|
||||
g_value_init( &save_value, IM_TYPE_SAVE_STRING );
|
||||
if( !g_value_transform( &value, &save_value ) )
|
||||
return( -1 );
|
||||
printf( "%s\n", im_save_string_get( &save_value ) );
|
||||
g_value_unset( &save_value );
|
||||
}
|
||||
else {
|
||||
char *str_value;
|
||||
|
||||
str_value = g_strdup_value_contents( &value );
|
||||
printf( "%s\n", str_value );
|
||||
g_free( str_value );
|
||||
}
|
||||
|
||||
g_value_unset( &value );
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
int
|
||||
main( int argc, char *argv[] )
|
||||
{
|
||||
GOptionContext *context;
|
||||
GError *error = NULL;
|
||||
int i;
|
||||
int result;
|
||||
|
||||
if( im_init_world( argv[0] ) )
|
||||
error_exit( "unable to start VIPS" );
|
||||
|
||||
context = g_option_context_new( _( "- print image header" ) );
|
||||
|
||||
g_option_context_add_main_entries( context,
|
||||
main_option, GETTEXT_PACKAGE );
|
||||
g_option_context_add_group( context, im_get_option_group() );
|
||||
|
||||
if( !g_option_context_parse( context, &argc, &argv, &error ) ) {
|
||||
if( error ) {
|
||||
fprintf( stderr, "%s\n", error->message );
|
||||
g_error_free( error );
|
||||
}
|
||||
|
||||
error_exit( "try \"%s --help\"", g_get_prgname() );
|
||||
}
|
||||
|
||||
g_option_context_free( context );
|
||||
|
||||
result = 0;
|
||||
|
||||
for( i = 1; i < argc; i++ ) {
|
||||
IMAGE *im;
|
||||
|
||||
if( !(im = im_open( argv[i], "r" )) ) {
|
||||
print_error( "%s: unable to open", argv[i] );
|
||||
result = 1;
|
||||
}
|
||||
|
||||
if( im && print_header( im ) ) {
|
||||
print_error( "%s: unable to print header", argv[i] );
|
||||
result = 1;
|
||||
}
|
||||
|
||||
if( im )
|
||||
im_close( im );
|
||||
}
|
||||
|
||||
return( result );
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
/* @(#) Prints the values of a file
|
||||
* @(#) Result is printed in stderr output
|
||||
* @(#)
|
||||
* @(#) Usage: printlines infile
|
||||
* @(#)
|
||||
*
|
||||
* Copyright: 1990, N. Dessipris.
|
||||
*
|
||||
* Author: Nicos Dessipris
|
||||
* Written on: 03/08/1990
|
||||
* Modified on:
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file is part of VIPS.
|
||||
|
||||
VIPS is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
#include <vips/intl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
IMAGE *in;
|
||||
|
||||
if ( (argc != 2)||(argv[1][0] == '-') )
|
||||
error_exit( "Usage:\n%s infile\n\n\
|
||||
Image is printed in stderr\n", argv[0]);
|
||||
|
||||
if( im_init_world( argv[0] ) )
|
||||
error_exit( "unable to start VIPS" );
|
||||
|
||||
if ((in = im_open(argv[1],"r")) == NULL)
|
||||
error_exit("Unable to open %s for input", argv[1]);
|
||||
|
||||
if (im_printlines(in) == -1)
|
||||
error_exit("unable to im_printlines");
|
||||
|
||||
im_close(in);
|
||||
|
||||
return(0);
|
||||
}
|
@ -1,978 +0,0 @@
|
||||
/* VIPS universal main program.
|
||||
*
|
||||
* J. Cupitt, 8/4/93.
|
||||
* 12/5/06
|
||||
* - use GOption. g_*_prgname()
|
||||
* 16/7/06
|
||||
* - hmm, was broken for function name as argv1 case
|
||||
* 11/7/06
|
||||
* - add "all" option to -l
|
||||
* 14/7/06
|
||||
* - ignore "--" arguments.
|
||||
* 2/9/06
|
||||
* - do less init ... im_init_world() does more now
|
||||
* 18/8/06
|
||||
* - use IM_EXEEXT
|
||||
* 16/10/06
|
||||
* - add --version
|
||||
* 17/10/06
|
||||
* - add --swig
|
||||
* - cleanups
|
||||
* - remove --swig again, sigh
|
||||
* - add throw() decls to C++ to help SWIG
|
||||
* 14/1/07
|
||||
* - add --list packages
|
||||
* 26/2/07
|
||||
* - add input *VEC arg types to C++ binding
|
||||
* 17/8/08
|
||||
* - add --list formats
|
||||
* 29/11/08
|
||||
* - add --list interpolators
|
||||
* 9/2/09
|
||||
* - and now we just have --list packages/classes/package-name
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file is part of VIPS.
|
||||
|
||||
VIPS is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
#define DEBUG_FATAL
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
#include <vips/intl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <locale.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
|
||||
#ifdef OS_WIN32
|
||||
#define strcasecmp(a,b) _stricmp(a,b)
|
||||
#endif
|
||||
|
||||
static char *main_option_list = NULL;
|
||||
static char *main_option_usage = NULL;
|
||||
static char *main_option_plugin = NULL;
|
||||
static gboolean main_option_links;
|
||||
static char *main_option_cpph = NULL;
|
||||
static char *main_option_cppc = NULL;
|
||||
static gboolean *main_option_version;
|
||||
|
||||
static GOptionEntry main_option[] = {
|
||||
{ "list", 'l', 0, G_OPTION_ARG_STRING, &main_option_list,
|
||||
N_( "list operations in PACKAGE "
|
||||
"(or \"all\", \"packages\", \"classes\")" ),
|
||||
"PACKAGE" },
|
||||
{ "usage", 'u', 0, G_OPTION_ARG_STRING, &main_option_usage,
|
||||
N_( "show usage message for OPERATION" ),
|
||||
"OPERATION" },
|
||||
{ "plugin", 'p', 0, G_OPTION_ARG_FILENAME, &main_option_plugin,
|
||||
N_( "load PLUGIN" ),
|
||||
"PLUGIN" },
|
||||
{ "links", 'k', 0, G_OPTION_ARG_NONE, &main_option_links,
|
||||
N_( "print link lines for all operations" ), NULL },
|
||||
{ "cpph", 'h', 0, G_OPTION_ARG_STRING, &main_option_cpph,
|
||||
N_( "print C++ decls for PACKAGE (or \"all\")" ),
|
||||
"PACKAGE" },
|
||||
{ "cppc", 'c', 0, G_OPTION_ARG_STRING, &main_option_cppc,
|
||||
N_( "print C++ binding for PACKAGE (or \"all\")" ),
|
||||
"PACKAGE" },
|
||||
{ "version", 'v', 0, G_OPTION_ARG_NONE, &main_option_version,
|
||||
N_( "print im_version_string" ), NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
typedef void *(*map_name_fn)( im_function * );
|
||||
|
||||
/* Loop over a package.
|
||||
*/
|
||||
static void *
|
||||
map_package( im_package *pack, map_name_fn fn )
|
||||
{
|
||||
int i;
|
||||
void *result;
|
||||
|
||||
for( i = 0; i < pack->nfuncs; i++ )
|
||||
if( (result = fn( pack->table[i] )) )
|
||||
return( result );
|
||||
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
/* Apply a function to a vips operation, or map over a package of operations.
|
||||
*/
|
||||
static void *
|
||||
map_name( const char *name, map_name_fn fn )
|
||||
{
|
||||
im_package *pack;
|
||||
im_function *func;
|
||||
|
||||
if( strcmp( name, "all" ) == 0 )
|
||||
/* Do all packages.
|
||||
*/
|
||||
im_map_packages( (VSListMap2Fn) map_package, fn );
|
||||
else if( (pack = im_find_package( name )) )
|
||||
/* Do one package.
|
||||
*/
|
||||
map_package( pack, fn );
|
||||
else if( (func = im_find_function( name )) )
|
||||
/* Do a single function.
|
||||
*/
|
||||
fn( func );
|
||||
else {
|
||||
im_error( "map_name",
|
||||
_( "no package or function \"%s\"" ), name );
|
||||
return( fn );
|
||||
}
|
||||
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
static void *
|
||||
list_package( im_package *pack )
|
||||
{
|
||||
printf( "%-20s - %d operations\n", pack->name, pack->nfuncs );
|
||||
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
static void *
|
||||
list_function( im_function *func )
|
||||
{
|
||||
printf( "%-20s - %s\n", func->name, _( func->desc ) );
|
||||
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
static void *
|
||||
list_class( VipsObjectClass *class )
|
||||
{
|
||||
vips_object_print_class( class );
|
||||
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
static void
|
||||
print_list( const char *name )
|
||||
{
|
||||
if( strcmp( name, "packages" ) == 0 )
|
||||
im_map_packages( (VSListMap2Fn) list_package, NULL );
|
||||
else if( strcmp( name, "classes" ) == 0 )
|
||||
vips_class_map_concrete_all( g_type_from_name( "VipsObject" ),
|
||||
(VipsClassMap) list_class, NULL );
|
||||
else {
|
||||
if( map_name( name, list_function ) )
|
||||
error_exit( "unknown package \"%s\"", name );
|
||||
}
|
||||
}
|
||||
|
||||
/* Is s1 a prefix of s2?
|
||||
*/
|
||||
static int
|
||||
isprefix( const char *s1, const char *s2 )
|
||||
{
|
||||
while( *s1 && *s1 == *s2 ) {
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
|
||||
return( *s1 == '\0' );
|
||||
}
|
||||
|
||||
/* Is s1 a postfix of s2?
|
||||
*/
|
||||
static int
|
||||
ispostfix( const char *s1, const char *s2 )
|
||||
{
|
||||
int l1 = strlen( s1 );
|
||||
int l2 = strlen( s2 );
|
||||
|
||||
if( l2 < l1 )
|
||||
return( 0 );
|
||||
|
||||
return( strcasecmp( s1, s2 + l2 - l1 ) == 0 );
|
||||
}
|
||||
|
||||
/* Print "ln -s" lines for this package.
|
||||
*/
|
||||
static void *
|
||||
print_links( im_package *pack )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < pack->nfuncs; i++ )
|
||||
printf( "rm -f %s" IM_EXEEXT "; "
|
||||
"ln -s vips" IM_EXEEXT " %s" IM_EXEEXT "\n",
|
||||
pack->table[i]->name, pack->table[i]->name );
|
||||
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
/* Does a function have any printing output?
|
||||
*/
|
||||
static int
|
||||
has_print( im_function *fn )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < fn->argc; i++ )
|
||||
if( fn->argv[i].print )
|
||||
return( -1 );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/* Print a usage string from an im_function descriptor.
|
||||
*/
|
||||
static void
|
||||
usage( im_function *fn )
|
||||
{
|
||||
int i;
|
||||
im_package *pack = im_package_of_function( fn->name );
|
||||
|
||||
/* Don't print the prgname if we're being run as a symlink.
|
||||
*/
|
||||
fprintf( stderr, "usage: " );
|
||||
if( im_isprefix( "vips", g_get_prgname() ) )
|
||||
fprintf( stderr, "%s ", g_get_prgname() );
|
||||
fprintf( stderr, "%s ", fn->name );
|
||||
|
||||
/* Print args requiring command-line input.
|
||||
*/
|
||||
for( i = 0; i < fn->argc; i++ )
|
||||
if( fn->argv[i].desc->flags & IM_TYPE_ARG )
|
||||
fprintf( stderr, "%s ", fn->argv[i].name );
|
||||
|
||||
/* Print types of command line args.
|
||||
*/
|
||||
fprintf( stderr, "\nwhere:\n" );
|
||||
for( i = 0; i < fn->argc; i++ )
|
||||
if( fn->argv[i].desc->flags & IM_TYPE_ARG )
|
||||
fprintf( stderr, "\t%s is of type \"%s\"\n",
|
||||
fn->argv[i].name, fn->argv[i].desc->type );
|
||||
|
||||
/* Print output print args.
|
||||
*/
|
||||
if( has_print( fn ) ) {
|
||||
fprintf( stderr, "prints:\n" );
|
||||
for( i = 0; i < fn->argc; i++ )
|
||||
if( fn->argv[i].print )
|
||||
fprintf( stderr, "\t%s of type \"%s\"\n",
|
||||
fn->argv[i].name,
|
||||
fn->argv[i].desc->type );
|
||||
}
|
||||
|
||||
/* Print description of this function, and package it comes from.
|
||||
*/
|
||||
fprintf( stderr, "%s", _( fn->desc ) );
|
||||
if( pack )
|
||||
fprintf( stderr, ", from package \"%s\"", pack->name );
|
||||
fprintf( stderr, "\n" );
|
||||
|
||||
/* Print any flags this function has.
|
||||
*/
|
||||
fprintf( stderr, "flags: " );
|
||||
if( fn->flags & IM_FN_PIO )
|
||||
fprintf( stderr, "(PIO function) " );
|
||||
else
|
||||
fprintf( stderr, "(WIO function) " );
|
||||
if( fn->flags & IM_FN_TRANSFORM )
|
||||
fprintf( stderr, "(coordinate transformer) " );
|
||||
else
|
||||
fprintf( stderr, "(no coordinate transformation) " );
|
||||
if( fn->flags & IM_FN_PTOP )
|
||||
fprintf( stderr, "(point-to-point operation) " );
|
||||
else
|
||||
fprintf( stderr, "(area operation) " );
|
||||
if( fn->flags & IM_FN_NOCACHE )
|
||||
fprintf( stderr, "(nocache operation) " );
|
||||
else
|
||||
fprintf( stderr, "(result can be cached) " );
|
||||
|
||||
fprintf( stderr, "\n" );
|
||||
}
|
||||
|
||||
/* Convert VIPS type name to C++ type name. NULL for type unsupported by C++
|
||||
* layer.
|
||||
*/
|
||||
static char *
|
||||
vips2cpp( im_type_desc *ty )
|
||||
{
|
||||
int k;
|
||||
|
||||
/* VIPS types.
|
||||
*/
|
||||
static char *vtypes[] = {
|
||||
IM_TYPE_DOUBLE,
|
||||
IM_TYPE_INT,
|
||||
IM_TYPE_COMPLEX,
|
||||
IM_TYPE_STRING,
|
||||
IM_TYPE_IMAGE,
|
||||
IM_TYPE_IMASK,
|
||||
IM_TYPE_DMASK,
|
||||
IM_TYPE_DISPLAY,
|
||||
IM_TYPE_IMAGEVEC,
|
||||
IM_TYPE_DOUBLEVEC,
|
||||
IM_TYPE_INTVEC
|
||||
};
|
||||
|
||||
/* Corresponding C++ types.
|
||||
*/
|
||||
static char *ctypes[] = {
|
||||
"double",
|
||||
"int",
|
||||
"std::complex<double>",
|
||||
"char*",
|
||||
"VImage",
|
||||
"VIMask",
|
||||
"VDMask",
|
||||
"VDisplay",
|
||||
"std::vector<VImage>",
|
||||
"std::vector<double>",
|
||||
"std::vector<int>"
|
||||
};
|
||||
|
||||
for( k = 0; k < IM_NUMBER( vtypes ); k++ )
|
||||
if( strcmp( ty->type, vtypes[k] ) == 0 )
|
||||
return( ctypes[k] );
|
||||
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
/* Test a function definition for C++ suitability.
|
||||
*/
|
||||
static int
|
||||
is_cppable( im_function *fn )
|
||||
{
|
||||
int j;
|
||||
|
||||
/* Check we know all the types.
|
||||
*/
|
||||
for( j = 0; j < fn->argc; j++ ) {
|
||||
im_type_desc *ty = fn->argv[j].desc;
|
||||
|
||||
if( !vips2cpp( ty ) )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/* We dont wrap output IMAGEVEC/DOUBLEVEC/INTVEC.
|
||||
*/
|
||||
for( j = 0; j < fn->argc; j++ ) {
|
||||
im_type_desc *ty = fn->argv[j].desc;
|
||||
|
||||
if( ty->flags & IM_TYPE_OUTPUT )
|
||||
if( strcmp( ty->type, IM_TYPE_IMAGEVEC ) == 0 ||
|
||||
strcmp( ty->type, IM_TYPE_DOUBLEVEC ) == 0 ||
|
||||
strcmp( ty->type, IM_TYPE_INTVEC ) == 0 )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/* Must be at least one image argument (input or output) ... since we
|
||||
* get inserted in the VImage class. Other funcs get wrapped by hand.
|
||||
*/
|
||||
for( j = 0; j < fn->argc; j++ )
|
||||
if( strcmp( fn->argv[j].desc->type, IM_TYPE_IMAGE ) == 0 )
|
||||
break;
|
||||
if( j == fn->argc )
|
||||
return( 0 );
|
||||
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
/* Search for the first output arg, and the first IMAGE input arg.
|
||||
*/
|
||||
static void
|
||||
find_ioargs( im_function *fn, int *ia, int *oa )
|
||||
{
|
||||
int j;
|
||||
|
||||
/* Look for first output arg - this will be the result of the
|
||||
* function.
|
||||
*/
|
||||
*oa = -1;
|
||||
for( j = 0; j < fn->argc; j++ ) {
|
||||
im_type_desc *ty = fn->argv[j].desc;
|
||||
|
||||
if( ty->flags & IM_TYPE_OUTPUT ) {
|
||||
*oa = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Look for first input IMAGE arg. This will become the implicit
|
||||
* "this" arg.
|
||||
*/
|
||||
*ia = -1;
|
||||
for( j = 0; j < fn->argc; j++ ) {
|
||||
im_type_desc *ty = fn->argv[j].desc;
|
||||
|
||||
if( !(ty->flags & IM_TYPE_OUTPUT) &&
|
||||
strcmp( ty->type, IM_TYPE_IMAGE ) == 0 ) {
|
||||
*ia = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Turn a VIPS name into a C++ name. Eg. im_lintra_vec becomes lin.
|
||||
*/
|
||||
static void
|
||||
c2cpp_name( const char *in, char *out )
|
||||
{
|
||||
/* chop off "im_" prefix.
|
||||
*/
|
||||
if( isprefix( "im_", in ) )
|
||||
strcpy( out, in + 3 );
|
||||
else
|
||||
strcpy( out, in );
|
||||
|
||||
/* Drop "_vec" postfix (eg. so im_lintra_vec becomes lintra). We rely
|
||||
* on overloading to distinguish conflicts.
|
||||
*/
|
||||
if( ispostfix( "_vec", out ) )
|
||||
out[strlen( out ) - 4] = '\0';
|
||||
|
||||
/* Drop "const" postfix (eg. so im_eorimageconst becomes eorimage).
|
||||
*/
|
||||
if( ispostfix( "const", out ) )
|
||||
out[strlen( out ) - 5] = '\0';
|
||||
|
||||
/* Drop "tra" postfix (eg. so im_costra becomes cos).
|
||||
*/
|
||||
if( ispostfix( "tra", out ) )
|
||||
out[strlen( out ) - 3] = '\0';
|
||||
}
|
||||
|
||||
/* Print prototype for a function (ie. will be followed by code).
|
||||
*
|
||||
* Eg.:
|
||||
* VImage VImage::lin( double a, double b ) throw( VError )
|
||||
*/
|
||||
static void *
|
||||
print_cppproto( im_function *fn )
|
||||
{
|
||||
int j;
|
||||
char name[4096];
|
||||
int oa, ia;
|
||||
int flg;
|
||||
|
||||
/* If it's not cppable, do nothing.
|
||||
*/
|
||||
if( !is_cppable( fn ) )
|
||||
return( NULL );
|
||||
|
||||
/* Make C++ name.
|
||||
*/
|
||||
c2cpp_name( fn->name, name );
|
||||
|
||||
/* Find input and output args.
|
||||
*/
|
||||
find_ioargs( fn, &ia, &oa );
|
||||
|
||||
/* Print output type.
|
||||
*/
|
||||
if( oa == -1 )
|
||||
printf( "void " );
|
||||
else
|
||||
printf( "%s ", vips2cpp( fn->argv[oa].desc ) );
|
||||
|
||||
printf( "VImage::%s(", name );
|
||||
|
||||
/* Print arg list.
|
||||
*/
|
||||
flg = 0;
|
||||
for( j = 0; j < fn->argc; j++ ) {
|
||||
im_type_desc *ty = fn->argv[j].desc;
|
||||
|
||||
/* Skip ia and oa.
|
||||
*/
|
||||
if( j == ia || j == oa )
|
||||
continue;
|
||||
|
||||
/* Print arg type.
|
||||
*/
|
||||
if( flg )
|
||||
printf( ", %s", vips2cpp( ty ) );
|
||||
else {
|
||||
printf( " %s", vips2cpp( ty ) );
|
||||
flg = 1;
|
||||
}
|
||||
|
||||
/* If it's an putput arg, print a "&" to make a reference
|
||||
* argument.
|
||||
*/
|
||||
if( ty->flags & IM_TYPE_OUTPUT )
|
||||
printf( "&" );
|
||||
|
||||
/* Print arg name.
|
||||
*/
|
||||
printf( " %s", fn->argv[j].name );
|
||||
}
|
||||
|
||||
/* End of arg list!
|
||||
*/
|
||||
if( flg )
|
||||
printf( " " );
|
||||
printf( ") throw( VError )\n" );
|
||||
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
/* Print cpp decl for a function.
|
||||
*
|
||||
* Eg.
|
||||
* VImage lin( double, double ) throw( VError );
|
||||
*/
|
||||
static void *
|
||||
print_cppdecl( im_function *fn )
|
||||
{
|
||||
int j;
|
||||
char name[4096];
|
||||
int oa, ia;
|
||||
int flg;
|
||||
|
||||
/* If it's not cppable, do nothing.
|
||||
*/
|
||||
if( !is_cppable( fn ) )
|
||||
return( NULL );
|
||||
|
||||
/* Make C++ name.
|
||||
*/
|
||||
c2cpp_name( fn->name, name );
|
||||
|
||||
/* Find input and output args.
|
||||
*/
|
||||
find_ioargs( fn, &ia, &oa );
|
||||
if( ia == -1 )
|
||||
/* No input image, so make it a static in the class
|
||||
* declaration.
|
||||
*/
|
||||
printf( "static " );
|
||||
|
||||
/* Print output type.
|
||||
*/
|
||||
if( oa == -1 )
|
||||
printf( "void " );
|
||||
else
|
||||
printf( "%s ", vips2cpp( fn->argv[oa].desc ) );
|
||||
|
||||
/* Print function name and start arg list.
|
||||
*/
|
||||
printf( "%s(", name );
|
||||
|
||||
/* Print arg list.
|
||||
*/
|
||||
flg = 0;
|
||||
for( j = 0; j < fn->argc; j++ ) {
|
||||
im_type_desc *ty = fn->argv[j].desc;
|
||||
|
||||
/* Skip ia and oa.
|
||||
*/
|
||||
if( j == ia || j == oa )
|
||||
continue;
|
||||
|
||||
/* Print arg type.
|
||||
*/
|
||||
if( flg )
|
||||
printf( ", %s", vips2cpp( ty ) );
|
||||
else {
|
||||
printf( " %s", vips2cpp( ty ) );
|
||||
flg = 1;
|
||||
}
|
||||
|
||||
/* If it's an putput arg, print a "&" to make a reference
|
||||
* argument.
|
||||
*/
|
||||
if( ty->flags & IM_TYPE_OUTPUT )
|
||||
printf( "&" );
|
||||
}
|
||||
|
||||
/* End of arg list!
|
||||
*/
|
||||
if( flg )
|
||||
printf( " " );
|
||||
|
||||
printf( ") throw( VError );\n" );
|
||||
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
static void
|
||||
print_invec( int j, const char *arg,
|
||||
const char *vips_name, const char *c_name, const char *extract )
|
||||
{
|
||||
printf( "\t((%s*) _vec.data(%d))->n = %s.size();\n",
|
||||
vips_name, j, arg );
|
||||
printf( "\t((%s*) _vec.data(%d))->vec = new %s[%s.size()];\n",
|
||||
vips_name, j, c_name, arg );
|
||||
printf( "\tfor( unsigned int i = 0; i < %s.size(); i++ )\n",
|
||||
arg );
|
||||
printf( "\t\t((%s*) _vec.data(%d))->vec[i] = %s[i]%s;\n",
|
||||
vips_name, j, arg, extract );
|
||||
}
|
||||
|
||||
/* Print the definition for a function.
|
||||
*/
|
||||
static void *
|
||||
print_cppdef( im_function *fn )
|
||||
{
|
||||
int j;
|
||||
int ia, oa;
|
||||
|
||||
/* If it's not cppable, do nothing.
|
||||
*/
|
||||
if( !is_cppable( fn ) )
|
||||
return( NULL );
|
||||
|
||||
find_ioargs( fn, &ia, &oa );
|
||||
|
||||
printf( "// %s: %s\n", fn->name, _( fn->desc ) );
|
||||
print_cppproto( fn );
|
||||
printf( "{\n" );
|
||||
|
||||
/* Declare the implicit input image.
|
||||
*/
|
||||
if( ia != -1 )
|
||||
printf( "\tVImage %s = *this;\n", fn->argv[ia].name );
|
||||
|
||||
/* Declare return value, if any.
|
||||
*/
|
||||
if( oa != -1 )
|
||||
printf( "\t%s %s;\n\n",
|
||||
vips2cpp( fn->argv[oa].desc ),
|
||||
fn->argv[oa].name );
|
||||
|
||||
/* Declare the arg vector.
|
||||
*/
|
||||
printf( "\tVargv _vec( \"%s\" );\n\n", fn->name );
|
||||
|
||||
/* Create the input args.
|
||||
*/
|
||||
for( j = 0; j < fn->argc; j++ ) {
|
||||
im_type_desc *ty = fn->argv[j].desc;
|
||||
|
||||
/* Images are special - have to init the vector, even
|
||||
* for output args. Have to translate VImage.
|
||||
*/
|
||||
if( strcmp( ty->type, IM_TYPE_IMAGE ) == 0 ) {
|
||||
printf( "\t_vec.data(%d) = %s.image();\n",
|
||||
j, fn->argv[j].name );
|
||||
continue;
|
||||
}
|
||||
|
||||
/* For output masks, we have to set an input filename. Not
|
||||
* freed, so constant string is OK.
|
||||
*/
|
||||
if( (ty->flags & IM_TYPE_OUTPUT) &&
|
||||
(strcmp( ty->type, IM_TYPE_IMASK ) == 0 ||
|
||||
strcmp( ty->type, IM_TYPE_DMASK ) == 0) ) {
|
||||
printf( "\t((im_mask_object*) _vec.data(%d))->name = "
|
||||
"(char*)\"noname\";\n", j );
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Skip other output args.
|
||||
*/
|
||||
if( ty->flags & IM_TYPE_OUTPUT )
|
||||
continue;
|
||||
|
||||
if( strcmp( ty->type, IM_TYPE_IMASK ) == 0 )
|
||||
/* Mask types are different - have to use
|
||||
* im_mask_object.
|
||||
*/
|
||||
printf( "\t((im_mask_object*) "
|
||||
"_vec.data(%d))->mask = %s.mask().iptr;\n",
|
||||
j, fn->argv[j].name );
|
||||
else if( strcmp( ty->type, IM_TYPE_DMASK ) == 0 )
|
||||
printf( "\t((im_mask_object*) "
|
||||
"_vec.data(%d))->mask = %s.mask().dptr;\n",
|
||||
j, fn->argv[j].name );
|
||||
else if( strcmp( ty->type, IM_TYPE_DISPLAY ) == 0 )
|
||||
/* Display have to use VDisplay.
|
||||
*/
|
||||
printf( "\t_vec.data(%d) = %s.disp();\n",
|
||||
j, fn->argv[j].name );
|
||||
else if( strcmp( ty->type, IM_TYPE_STRING ) == 0 )
|
||||
/* Zap input strings directly into _vec.
|
||||
*/
|
||||
printf( "\t_vec.data(%d) = (im_object) %s;\n",
|
||||
j, fn->argv[j].name );
|
||||
else if( strcmp( ty->type, IM_TYPE_IMAGEVEC ) == 0 )
|
||||
print_invec( j, fn->argv[j].name,
|
||||
"im_imagevec_object", "IMAGE *", ".image()" );
|
||||
else if( strcmp( ty->type, IM_TYPE_DOUBLEVEC ) == 0 )
|
||||
print_invec( j, fn->argv[j].name,
|
||||
"im_doublevec_object", "double", "" );
|
||||
else if( strcmp( ty->type, IM_TYPE_INTVEC ) == 0 )
|
||||
print_invec( j, fn->argv[j].name,
|
||||
"im_intvec_object", "int", "" );
|
||||
else
|
||||
/* Just use vips2cpp().
|
||||
*/
|
||||
printf( "\t*((%s*) _vec.data(%d)) = %s;\n",
|
||||
vips2cpp( ty ), j, fn->argv[j].name );
|
||||
}
|
||||
|
||||
/* Call function.
|
||||
*/
|
||||
printf( "\t_vec.call();\n" );
|
||||
|
||||
/* Extract output args.
|
||||
*/
|
||||
for( j = 0; j < fn->argc; j++ ) {
|
||||
im_type_desc *ty = fn->argv[j].desc;
|
||||
|
||||
/* Skip input args.
|
||||
*/
|
||||
if( !(ty->flags & IM_TYPE_OUTPUT) )
|
||||
continue;
|
||||
|
||||
/* Skip images (done on input side, really).
|
||||
*/
|
||||
if( strcmp( ty->type, IM_TYPE_IMAGE ) == 0 )
|
||||
continue;
|
||||
|
||||
if( strcmp( ty->type, IM_TYPE_IMASK ) == 0 ||
|
||||
strcmp( ty->type, IM_TYPE_DMASK ) == 0 )
|
||||
/* Mask types are different - have to use
|
||||
* im_mask_object.
|
||||
*/
|
||||
printf( "\t%s.embed( (DOUBLEMASK *)((im_mask_object*)"
|
||||
"_vec.data(%d))->mask );\n",
|
||||
fn->argv[j].name, j );
|
||||
else if( strcmp( ty->type, IM_TYPE_STRING ) == 0 )
|
||||
/* Strings are grabbed out of the vec.
|
||||
*/
|
||||
printf( "\t%s = (char*) _vec.data(%d);\n",
|
||||
fn->argv[j].name, j );
|
||||
else
|
||||
/* Just use vips2cpp().
|
||||
*/
|
||||
printf( "\t%s = *((%s*)_vec.data(%d));\n",
|
||||
fn->argv[j].name, vips2cpp( ty ), j );
|
||||
}
|
||||
|
||||
/* Note dependancies if out is an image and this function uses
|
||||
* PIO.
|
||||
*/
|
||||
if( oa != -1 ) {
|
||||
im_type_desc *ty = fn->argv[oa].desc;
|
||||
|
||||
if( strcmp( ty->type, IM_TYPE_IMAGE ) == 0 &&
|
||||
(fn->flags & IM_FN_PIO) ) {
|
||||
/* Loop for all input args again ..
|
||||
*/
|
||||
for( j = 0; j < fn->argc; j++ ) {
|
||||
im_type_desc *ty2 = fn->argv[j].desc;
|
||||
|
||||
/* Skip output args.
|
||||
*/
|
||||
if( ty2->flags & IM_TYPE_OUTPUT )
|
||||
continue;
|
||||
|
||||
/* Input image.
|
||||
*/
|
||||
if( strcmp( ty2->type, IM_TYPE_IMAGE ) == 0 )
|
||||
printf( "\t%s._ref->addref( "
|
||||
"%s._ref );\n",
|
||||
fn->argv[oa].name,
|
||||
fn->argv[j].name );
|
||||
else if( strcmp( ty2->type, IM_TYPE_IMAGEVEC )
|
||||
== 0 ) {
|
||||
/* The out depends on every image in
|
||||
* the input vector.
|
||||
*/
|
||||
printf( "\tfor( unsigned int i = 0; "
|
||||
"i < %s.size(); i++ )\n",
|
||||
fn->argv[j].name );
|
||||
printf( "\t\t%s._ref->addref( "
|
||||
"%s[i]._ref );\n",
|
||||
fn->argv[oa].name,
|
||||
fn->argv[j].name );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Return result.
|
||||
*/
|
||||
if( oa != -1 )
|
||||
printf( "\n\treturn( %s );\n", fn->argv[oa].name );
|
||||
|
||||
printf( "}\n\n" );
|
||||
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
/* Print C++ decls for function, package or all.
|
||||
*/
|
||||
static void
|
||||
print_cppdecls( char *name )
|
||||
{
|
||||
printf( "// this file automatically generated from\n"
|
||||
"// VIPS library %s\n", im_version_string() );
|
||||
|
||||
if( map_name( name, print_cppdecl ) )
|
||||
error_exit( "unknown package \"%s\"", name );
|
||||
}
|
||||
|
||||
/* Print C++ bindings for function, package or all.
|
||||
*/
|
||||
static void
|
||||
print_cppdefs( char *name )
|
||||
{
|
||||
printf( "// this file automatically generated from\n"
|
||||
"// VIPS library %s\n", im_version_string() );
|
||||
|
||||
if( map_name( name, print_cppdef ) )
|
||||
error_exit( "unknown package \"%s\"", name );
|
||||
}
|
||||
|
||||
/* VIPS universal main program.
|
||||
*/
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
GOptionContext *context;
|
||||
GError *error = NULL;
|
||||
im_function *fn;
|
||||
int i, j;
|
||||
|
||||
if( im_init_world( argv[0] ) )
|
||||
error_exit( "unable to start VIPS" );
|
||||
#ifdef DEBUG_FATAL
|
||||
/* Set masks for debugging ... stop on any problem.
|
||||
*/
|
||||
g_log_set_always_fatal(
|
||||
G_LOG_FLAG_RECURSION |
|
||||
G_LOG_FLAG_FATAL |
|
||||
G_LOG_LEVEL_ERROR |
|
||||
G_LOG_LEVEL_CRITICAL |
|
||||
G_LOG_LEVEL_WARNING );
|
||||
|
||||
fprintf( stderr, "*** DEBUG_FATAL: will abort() on first warning\n" );
|
||||
#endif /*!DEBUG_FATAL*/
|
||||
|
||||
context = g_option_context_new( _( "- VIPS driver program" ) );
|
||||
|
||||
g_option_context_add_main_entries( context,
|
||||
main_option, GETTEXT_PACKAGE );
|
||||
g_option_context_add_group( context, im_get_option_group() );
|
||||
|
||||
if( !g_option_context_parse( context, &argc, &argv, &error ) ) {
|
||||
if( error ) {
|
||||
fprintf( stderr, "%s\n", error->message );
|
||||
g_error_free( error );
|
||||
}
|
||||
|
||||
error_exit( "try \"%s --help\"", g_get_prgname() );
|
||||
}
|
||||
|
||||
g_option_context_free( context );
|
||||
|
||||
if( main_option_plugin ) {
|
||||
if( !im_load_plugin( main_option_plugin ) )
|
||||
error_exit( "unable to load plugin %s",
|
||||
main_option_plugin );
|
||||
}
|
||||
if( main_option_cpph )
|
||||
print_cppdecls( main_option_cpph );
|
||||
if( main_option_cppc )
|
||||
print_cppdefs( main_option_cppc );
|
||||
if( main_option_links )
|
||||
im_map_packages( (VSListMap2Fn) print_links, NULL );
|
||||
if( main_option_list )
|
||||
print_list( main_option_list );
|
||||
if( main_option_usage ) {
|
||||
if( !(fn = im_find_function( main_option_usage )) )
|
||||
error_exit( "unknown operation %s", main_option_usage );
|
||||
usage( fn );
|
||||
}
|
||||
if( main_option_version )
|
||||
printf( "vips-%s\n", im_version_string() );
|
||||
|
||||
/* Remove any "--" argument. If one of our arguments is a negative
|
||||
* number, the user will need to have added the "--" flag to stop
|
||||
* GOption parsing. But "--" is still passed down to us and we need to
|
||||
* ignore it.
|
||||
*/
|
||||
for( i = 1; i < argc - 1; i++ )
|
||||
if( strcmp( argv[i], "--" ) == 0 ) {
|
||||
for( j = i; j < argc; j++ )
|
||||
argv[j] = argv[j + 1];
|
||||
|
||||
argc -= 1;
|
||||
}
|
||||
|
||||
/* Should we try to run the thing we are named as?
|
||||
*/
|
||||
if( !im_isprefix( "vips", g_get_prgname() ) ) {
|
||||
char name[256];
|
||||
|
||||
/* Drop any .exe suffix.
|
||||
*/
|
||||
im_strncpy( name, g_get_prgname(), 256 );
|
||||
if( ispostfix( ".exe", name ) )
|
||||
name[strlen( name ) - 4] = '\0';
|
||||
|
||||
/* If unknown, try with "im_" prepended.
|
||||
*/
|
||||
if( !(fn = im_find_function( name )) ) {
|
||||
im_snprintf( name, 256, "im_%s", g_get_prgname() );
|
||||
if( ispostfix( ".exe", name ) )
|
||||
name[strlen( name ) - 4] = '\0';
|
||||
|
||||
if( !(fn = im_find_function( name )) )
|
||||
error_exit( "unknown function" );
|
||||
}
|
||||
|
||||
/* Execute it!
|
||||
*/
|
||||
if( im_run_command( name, argc - 1, argv + 1 ) ) {
|
||||
usage( fn );
|
||||
error_exit( "error calling function" );
|
||||
}
|
||||
}
|
||||
else if( argc > 1 ) {
|
||||
/* Nope ... run the first arg instead.
|
||||
*/
|
||||
if( im_run_command( argv[1], argc - 2, argv + 2 ) ) {
|
||||
if( !(fn = im_find_function( argv[1] )) )
|
||||
error_exit( "unknown function" );
|
||||
usage( fn );
|
||||
error_exit( "error calling function" );
|
||||
}
|
||||
}
|
||||
|
||||
im_close_plugins();
|
||||
|
||||
return( 0 );
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
|
||||
bin_PROGRAMS = \
|
||||
find_mosaic \
|
||||
mergeup
|
||||
|
||||
find_mosaic_SOURCES = find_mosaic.c
|
||||
mergeup_SOURCES = mergeup.c
|
||||
|
||||
INCLUDES = -I${top_srcdir}/include @VIPS_CFLAGS@ @VIPS_INCLUDES@
|
||||
AM_LDFLAGS = @LDFLAGS@
|
||||
LDADD = @VIPS_CFLAGS@ ${top_builddir}/libsrc/libvips.la @VIPS_LIBS@
|
||||
|
@ -1,430 +0,0 @@
|
||||
/* Join together images.
|
||||
*
|
||||
* find_mosaic x y file_name <root>.0x0.v <root>.0x1.v ...
|
||||
*
|
||||
* Where the image has been take with patches named as
|
||||
*
|
||||
* . .
|
||||
* . .
|
||||
* <root>.0x1.v <root>.1x1.v ..
|
||||
* <root>.0x0.v <root>.1x0.v ..
|
||||
*
|
||||
* Uses im__find_lroverlap and im__find_tboverlap routines to make <root>.v.
|
||||
*
|
||||
* It stores the tie points between patches in a data_file.
|
||||
*
|
||||
* It uses partials on all IO by including tbmerge / lrmerge programs.
|
||||
*
|
||||
*
|
||||
* Copyright (C) Feb./1995, Ahmed. Abbood
|
||||
* National Gallery. London
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file is part of VIPS.
|
||||
|
||||
VIPS is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
#include <vips/intl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
|
||||
#define NUM_FILES 1000
|
||||
#define MAXPOINTS 60
|
||||
int xoverlap;
|
||||
int yoverlap;
|
||||
|
||||
extern int im_lrmerge();
|
||||
extern int im_merge_analysis();
|
||||
extern int im__find_lroverlap();
|
||||
extern int im__find_tboverlap();
|
||||
static int file_ptr = 0;
|
||||
static IMAGE *in[ NUM_FILES ];
|
||||
|
||||
|
||||
|
||||
/* Strategy: build a tree describing the sequence of joins we want. Walk the
|
||||
* tree assigning temporary file names, compile the tree into a linear
|
||||
* sequence of join commands.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Decoded file name info.
|
||||
*/
|
||||
static char *file_root = NULL;
|
||||
static char *output_file = NULL;
|
||||
static int width = 0; /* Number of frames across */
|
||||
static int height = 0; /* Number of frames down */
|
||||
|
||||
static int file_list[ NUM_FILES ];
|
||||
|
||||
|
||||
|
||||
|
||||
/* Find the root name of a file name. Return new, shorter, string.
|
||||
*/
|
||||
static char *
|
||||
find_root( name )
|
||||
char *name;
|
||||
{ char *out = strdup( name );
|
||||
char *p;
|
||||
|
||||
/* Chop off '.v'.
|
||||
*/
|
||||
if( !(p = strrchr( out, '.' )) ) {
|
||||
im_errormsg( "Bad file name format '%s'", name );
|
||||
free( out );
|
||||
return( NULL );
|
||||
}
|
||||
*p = '\0';
|
||||
|
||||
/* Chop off nxn.
|
||||
*/
|
||||
if( !(p = strrchr( out, '.' )) ) {
|
||||
im_errormsg( "Bad file name format '%s'", name );
|
||||
free( out );
|
||||
return( NULL );
|
||||
}
|
||||
*p = '\0';
|
||||
|
||||
return( out );
|
||||
}
|
||||
|
||||
/* Find the x position of a file name (extract n from <root>.nxm.v).
|
||||
*/
|
||||
static int
|
||||
find_x( name )
|
||||
char *name;
|
||||
{ int n;
|
||||
char *p;
|
||||
char *out = strdup( name );
|
||||
|
||||
/* Chop off '.v'.
|
||||
*/
|
||||
if( !(p = strrchr( out, '.' )) ) {
|
||||
im_errormsg( "Bad file name format '%s'", name );
|
||||
free( out );
|
||||
return( -1 );
|
||||
}
|
||||
*p = '\0';
|
||||
|
||||
/* Find '.nxm'.
|
||||
*/
|
||||
if( !(p = strrchr( out, '.' )) ) {
|
||||
im_errormsg( "Bad file name format '%s'", name );
|
||||
free( out );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
/* Read out x posn.
|
||||
*/
|
||||
if( sscanf( p, ".%dx%*d", &n ) != 1 ) {
|
||||
im_errormsg( "Bad file name format '%s'", name );
|
||||
free( out );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
return( n );
|
||||
}
|
||||
|
||||
/* Find the y position of a file name (extract m from <root>.nxm.v).
|
||||
*/
|
||||
static int
|
||||
find_y( name )
|
||||
char *name;
|
||||
{ int m;
|
||||
char *p;
|
||||
char *out = strdup( name );
|
||||
|
||||
/* Chop off '.v'.
|
||||
*/
|
||||
if( !(p = strrchr( out, '.' )) ) {
|
||||
im_errormsg( "Bad file name format '%s'", name );
|
||||
free( out );
|
||||
return( -1 );
|
||||
}
|
||||
*p = '\0';
|
||||
|
||||
/* Find '.nxm'.
|
||||
*/
|
||||
if( !(p = strrchr( out, '.' )) ) {
|
||||
im_errormsg( "Bad file name format '%s'", name );
|
||||
free( out );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
/* Read out y posn.
|
||||
*/
|
||||
if( sscanf( p, ".%*dx%d", &m ) != 1 ) {
|
||||
im_errormsg( "Bad file name format '%s'", name );
|
||||
free( out );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
free( out );
|
||||
return( m );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static int
|
||||
mosaic_analysis(int width, int height,IMAGE **inp, IMAGE *out,
|
||||
int xoff, int yoff, int *vxdisp, int *vydisp,int *hxdisp, int *hydisp) {
|
||||
|
||||
|
||||
|
||||
int i, j, dx, dy, curr_im, fx, fy;
|
||||
int halfcorsize, halfareasize;
|
||||
int mincorsize, minareasize;
|
||||
int prev_row, curr_row, curr_disp_x, curr_disp_y;
|
||||
double scale1, angle1, dx1, dy1;
|
||||
|
||||
|
||||
curr_im = -1;
|
||||
curr_disp_x = -1;
|
||||
curr_disp_y = -1;
|
||||
dy = -1;
|
||||
for(i=0; i<=height; i++){
|
||||
for(j=0; j<=width; j++){
|
||||
++curr_im;
|
||||
halfcorsize = 5;
|
||||
halfareasize = 14;
|
||||
dx = xoff - inp[curr_im]->Xsize;
|
||||
dy = yoff - inp[curr_im]->Ysize;
|
||||
|
||||
if( ( j < width ) && ( width > 0 ) ){
|
||||
if( dx < 0 ){
|
||||
mincorsize = (int)(inp[curr_im]->Xsize + dx - 1)/6;
|
||||
minareasize = (int)(inp[curr_im]->Xsize + dx
|
||||
- 3*halfcorsize -1)/2 - mincorsize;
|
||||
if(mincorsize > halfcorsize)
|
||||
mincorsize = halfcorsize;
|
||||
if( minareasize > 0 ){
|
||||
if( minareasize < halfareasize ){
|
||||
if( minareasize >
|
||||
(int)(halfcorsize +(int)(halfcorsize/2 + 1))){
|
||||
halfareasize = minareasize;
|
||||
}
|
||||
else if(mincorsize > 2){
|
||||
halfcorsize=mincorsize;
|
||||
halfareasize=(int)(mincorsize+mincorsize/2 +1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( ( inp[curr_im]->Xsize < xoff ) || ( inp[curr_im+1]->Xsize < xoff ) ||
|
||||
( inp[curr_im]->Ysize < yoff ) || ( inp[curr_im]->Ysize < yoff) ){
|
||||
++curr_disp_x;
|
||||
hxdisp[curr_disp_x] = 0;
|
||||
hydisp[curr_disp_x] = 0;
|
||||
}
|
||||
else{
|
||||
if ( im__find_lroverlap(inp[curr_im], inp[curr_im+1],
|
||||
out, 0,
|
||||
(int)(inp[curr_im]->Xsize -xoff/2),
|
||||
(int)(inp[curr_im]->Ysize /2),
|
||||
(int)(xoff/2), (int)(inp[curr_im+1]->Ysize /2),
|
||||
halfcorsize, halfareasize , &fx, &fy,
|
||||
&scale1, &angle1, &dx1, &dy1 ) == -1 )
|
||||
error_exit("Unable to im__find_lroverlap");
|
||||
|
||||
++curr_disp_x;
|
||||
hxdisp[curr_disp_x] = inp[curr_im]->Xsize - xoff + fx;
|
||||
hydisp[curr_disp_x] = fy;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( ( i < height ) && ( height > 0 ) ){
|
||||
curr_row = curr_im+1+(int)(width/2);
|
||||
prev_row = curr_im - width+(int)(width/2);
|
||||
halfcorsize = 5;
|
||||
halfareasize = 14;
|
||||
|
||||
if( dy < 0){
|
||||
mincorsize = (int)(inp[prev_row]->Ysize + dy - 1)/6;
|
||||
minareasize = (int)(inp[prev_row]->Ysize + dy
|
||||
- 3*halfcorsize -1)/2 - mincorsize;
|
||||
if(mincorsize > halfcorsize)
|
||||
mincorsize = halfcorsize;
|
||||
if( minareasize > 0 ){
|
||||
if( minareasize < halfareasize ){
|
||||
if( minareasize >
|
||||
(int)(halfcorsize +(int)(halfcorsize/2 + 1))){
|
||||
halfareasize = minareasize;
|
||||
}
|
||||
else if(mincorsize > 2){
|
||||
halfcorsize=mincorsize;
|
||||
halfareasize=(int)(mincorsize+mincorsize/2 +1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if( ( inp[curr_row]->Xsize < xoff ) || ( inp[prev_row]->Xsize < xoff ) ||
|
||||
( inp[curr_row]->Ysize < yoff ) || ( inp[prev_row]->Ysize < yoff ) ){
|
||||
++curr_disp_y;
|
||||
vxdisp[curr_disp_y] = 0;
|
||||
vydisp[curr_disp_y] = 0;
|
||||
}
|
||||
else{
|
||||
if ( im__find_tboverlap(inp[prev_row], inp[curr_row],
|
||||
out, 0,
|
||||
(int)(inp[prev_row]->Xsize/2 ),
|
||||
(int)(inp[prev_row]->Ysize - yoff/2 ),
|
||||
(int)(inp[curr_row]->Xsize/2 ), (int)(yoff/2),
|
||||
halfcorsize, halfareasize, &fx, &fy,
|
||||
&scale1, &angle1, &dx1, &dy1 ) == -1 )
|
||||
error_exit("Unable to im__find_tboverlap");
|
||||
|
||||
|
||||
++curr_disp_y;
|
||||
vxdisp[curr_disp_y] = fx;
|
||||
vydisp[curr_disp_y] = inp[prev_row]->Ysize - yoff + fy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ( 0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
main( argc, argv )
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int i, n, j, k;
|
||||
char name[ 1000 ];
|
||||
FILE *fp;
|
||||
char *r;
|
||||
IMAGE *out;
|
||||
int vxdisp[NUM_FILES + 1] ;
|
||||
int vydisp[NUM_FILES + 1] ;
|
||||
int hxdisp[NUM_FILES + 1] ;
|
||||
int hydisp[NUM_FILES + 1] ;
|
||||
|
||||
if( im_init_world( argv[0] ) )
|
||||
error_exit( "unable to start VIPS" );
|
||||
|
||||
/* Too many?
|
||||
*/
|
||||
if( argc > NUM_FILES + 1 )
|
||||
error_exit( "Too many files to merge" );
|
||||
for(i=0; i< NUM_FILES; i++)
|
||||
file_list[i] = 0;
|
||||
/* Too few?
|
||||
*/
|
||||
if( argc == 1 )
|
||||
error_exit( "usage: xoverlap yoverlap file_name "
|
||||
"<root>.0x0.v <root>.0x1.v ..." );
|
||||
xoverlap = atoi(argv[1]);
|
||||
yoverlap = atoi(argv[2]);
|
||||
fp = fopen( argv[3] , "w" );
|
||||
|
||||
for( i = 4; i < argc; i++ ){
|
||||
/* Find/check root.
|
||||
*/
|
||||
if( !file_root ) {
|
||||
file_root = find_root( argv[i] );
|
||||
if( !file_root )
|
||||
error_exit( "error at file_root" );
|
||||
}
|
||||
else {
|
||||
if( !(r = find_root( argv[i] )) )
|
||||
error_exit( "Error in reading parameters" );
|
||||
if( strcmp( r, file_root ) != 0 )
|
||||
error_exit( "Not all roots identical!" );
|
||||
}
|
||||
|
||||
/* Read out position.
|
||||
*/
|
||||
if( (n = find_x( argv[i] )) < 0 )
|
||||
error_exit( "Error in reading file name" );
|
||||
if( n > width - 1 )
|
||||
width = n;
|
||||
if( (n = find_y( argv[i] )) < 0 )
|
||||
error_exit( "Error in reading file name" );
|
||||
if( n > height - 1 )
|
||||
height = n;
|
||||
|
||||
file_list[n] +=1;
|
||||
}
|
||||
|
||||
/* Make output name. and store them in an array.
|
||||
*/
|
||||
if( !(out = im_open( "tmp.v", "t" )) )
|
||||
error_exit("unable to open file for output");
|
||||
|
||||
file_ptr =0;
|
||||
for(i=height; i>=0; i--)
|
||||
for(j=0; j<file_list[i]; j++){
|
||||
im_snprintf( name, 1024, "%s.%dx%d.v", file_root,j,i );
|
||||
output_file = strdup( name );
|
||||
if( !(in[file_ptr] = im_open( output_file, "r" )) )
|
||||
error_exit("unable to open %s for input",output_file);
|
||||
++file_ptr;
|
||||
|
||||
}
|
||||
|
||||
mosaic_analysis(width,height,in,out,xoverlap,yoverlap,vxdisp,vydisp,hxdisp,hydisp);
|
||||
k = 0;
|
||||
for( i=0; i<height; i++ ){
|
||||
for( j=0; j<width; j++ ){
|
||||
fprintf(fp,"%d %d ", hxdisp[k] , hydisp[k] );
|
||||
k++;
|
||||
}
|
||||
fprintf(fp,"\n");
|
||||
}
|
||||
|
||||
for( i=0; i<height; i++ )
|
||||
fprintf(fp,"%d %d\n", vxdisp[i] , vydisp[i] );
|
||||
|
||||
|
||||
for(i=0; i<file_ptr; i++)
|
||||
if( im_close(in[i]) == -1)
|
||||
error_exit("unable to close partial file");
|
||||
if( im_close(out) == -1)
|
||||
error_exit("unable to close\n ");
|
||||
fclose( fp );
|
||||
|
||||
|
||||
return( 0 );
|
||||
}
|
@ -1,559 +0,0 @@
|
||||
/* Join together images
|
||||
*
|
||||
* mergeup x y file_name output_dir <root>.0x0.v <root>.0x1.v ...
|
||||
*
|
||||
* Where the image has been take with patches named as
|
||||
*
|
||||
* . .
|
||||
* . .
|
||||
* <root>.0x1.v <root>.1x1.v ..
|
||||
* <root>.0x0.v <root>.1x0.v ..
|
||||
*
|
||||
*
|
||||
* Tries to generate optimal join sequence. Does not require any intermidiate
|
||||
* files for temporary storage.
|
||||
* It uses partials on all IO by including tbmerge / lrmerge programs.
|
||||
*
|
||||
*
|
||||
* Copyright (C) Feb./1995, Ahmed. Abbood
|
||||
* National Gallery. London
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file is part of VIPS.
|
||||
|
||||
VIPS is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
#include <vips/intl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
|
||||
#define NUM_FILES 1000
|
||||
#define MAXPOINTS 60
|
||||
|
||||
static int xoverlap;
|
||||
static int yoverlap;
|
||||
|
||||
static int file_ptr = 0;
|
||||
static IMAGE *in[ NUM_FILES ];
|
||||
|
||||
/* Strategy: build a tree describing the sequence of joins we want. Walk the
|
||||
* tree assigning temporary file names, compile the tree into a linear
|
||||
* sequence of join commands.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Decoded file name info.
|
||||
*/
|
||||
static char *file_root = NULL;
|
||||
static char *output_file = NULL;
|
||||
static int width = 0; /* Number of frames across */
|
||||
static int height = 0; /* Number of frames down */
|
||||
|
||||
static int file_list[ NUM_FILES ];
|
||||
|
||||
|
||||
static int
|
||||
im_phmerge( Rect *larea, Rect *rarea, Rect *outarea )
|
||||
{
|
||||
|
||||
Rect overlap;
|
||||
|
||||
|
||||
/* Compute overlap.
|
||||
*/
|
||||
im_rect_intersectrect( larea, rarea, &overlap );
|
||||
|
||||
outarea->width = rarea->left + rarea->width;
|
||||
outarea->height = overlap.height;
|
||||
outarea->top = overlap.top;
|
||||
outarea->left = larea->left;
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
im_pvmerge( Rect *tarea, Rect *barea, Rect *outarea )
|
||||
{
|
||||
|
||||
Rect overlap;
|
||||
|
||||
|
||||
/* Compute overlap.
|
||||
*/
|
||||
im_rect_intersectrect( tarea, barea, &overlap );
|
||||
|
||||
outarea->width = overlap.width;
|
||||
outarea->height = barea->top + barea->height ;
|
||||
outarea->left = overlap.left;
|
||||
outarea->top = tarea->top;
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static int
|
||||
merge_analysis(int width,int height,IMAGE **in,int xoff,
|
||||
int yoff,int *vxdisp,int *vydisp,int *hxdisp,
|
||||
int *hydisp,Rect *hrect,Rect *vrect)
|
||||
{
|
||||
int i,j;
|
||||
int curr_im,offset;
|
||||
int curr_x, curr_y;
|
||||
Rect larea, rarea, barea;
|
||||
|
||||
|
||||
|
||||
curr_im = -1;
|
||||
curr_x = -1;
|
||||
curr_y = -1;
|
||||
for(i=0; i<=height; i++){
|
||||
for(j=0; j<=width; j++){
|
||||
++curr_im;
|
||||
if( width == 0 ){
|
||||
++curr_x;
|
||||
hrect[curr_x].width = in[curr_im]->Xsize;
|
||||
hrect[curr_x].height= in[curr_im]->Ysize;
|
||||
hrect[curr_x].top = 0;
|
||||
hrect[curr_x].left = 0;
|
||||
}
|
||||
else{
|
||||
if( j == 0){
|
||||
++curr_x;
|
||||
|
||||
/* Area occupied by left image.
|
||||
*/
|
||||
larea.left = 0;
|
||||
larea.top = 0;
|
||||
larea.height = in[curr_im]->Ysize;
|
||||
larea.width = in[curr_im]->Xsize;
|
||||
/* Area occupied by right image.
|
||||
*/
|
||||
if( in[curr_im]->Xsize < xoff )
|
||||
offset = 0;
|
||||
else
|
||||
offset =xoff;
|
||||
rarea.left = in[curr_im]->Xsize - (offset + hxdisp[curr_x]) ;
|
||||
rarea.top = hydisp[curr_x];
|
||||
rarea.width = in[curr_im+1]->Xsize;
|
||||
rarea.height = in[curr_im+1]->Ysize;
|
||||
im_phmerge( &larea, &rarea, &hrect[curr_x] );
|
||||
}
|
||||
else if( j < width ){
|
||||
++curr_x;
|
||||
|
||||
/* Area occupied by right image.
|
||||
*/
|
||||
if( in[curr_im+1]->Xsize < xoff )
|
||||
offset = 0;
|
||||
else
|
||||
offset =xoff;
|
||||
|
||||
rarea.left = hrect[curr_x -1].width - (offset + hxdisp[curr_x]) ;
|
||||
rarea.top = hydisp[curr_x];
|
||||
rarea.width = in[curr_im+1]->Xsize;
|
||||
rarea.height = in[curr_im+1]->Ysize;
|
||||
im_phmerge( &hrect[curr_x -1], &rarea, &hrect[curr_x] );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( i > 0 ){
|
||||
++curr_y;
|
||||
|
||||
/* Area occupied by bottom image in output.
|
||||
*/
|
||||
barea.left = vxdisp[curr_y];
|
||||
barea.width = hrect[curr_x].width;
|
||||
barea.height = hrect[curr_x].height;
|
||||
if( in[curr_x - width]->Ysize < yoff )
|
||||
offset = 0;
|
||||
else
|
||||
offset = yoff;
|
||||
if( i == 1){
|
||||
barea.top = hrect[curr_x - width].height - offset - vydisp[curr_y] ;
|
||||
im_pvmerge( &hrect[curr_x - width], &barea, &vrect[curr_y] );
|
||||
}
|
||||
else{
|
||||
barea.top = vrect[curr_y - 1].height - yoff - vydisp[curr_y] ;
|
||||
im_pvmerge( &vrect[curr_y -1], &barea, &vrect[curr_y] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/* Find the root name of a file name. Return new, shorter, string.
|
||||
*/
|
||||
static char *
|
||||
find_root( name )
|
||||
char *name;
|
||||
{ char *out = strdup( name );
|
||||
char *p;
|
||||
|
||||
/* Chop off '.v'.
|
||||
*/
|
||||
if( !(p = strrchr( out, '.' )) ) {
|
||||
im_errormsg( "Bad file name format '%s'", name );
|
||||
free( out );
|
||||
return( NULL );
|
||||
}
|
||||
*p = '\0';
|
||||
|
||||
/* Chop off nxn.
|
||||
*/
|
||||
if( !(p = strrchr( out, '.' )) ) {
|
||||
im_errormsg( "Bad file name format '%s'", name );
|
||||
free( out );
|
||||
return( NULL );
|
||||
}
|
||||
*p = '\0';
|
||||
|
||||
return( out );
|
||||
}
|
||||
|
||||
/* Find the x position of a file name (extract n from <root>.nxm.v).
|
||||
*/
|
||||
static int
|
||||
find_x( name )
|
||||
char *name;
|
||||
{ int n;
|
||||
char *p;
|
||||
char *out = strdup( name );
|
||||
|
||||
/* Chop off '.v'.
|
||||
*/
|
||||
if( !(p = strrchr( out, '.' )) ) {
|
||||
im_errormsg( "Bad file name format '%s'", name );
|
||||
free( out );
|
||||
return( -1 );
|
||||
}
|
||||
*p = '\0';
|
||||
|
||||
/* Find '.nxm'.
|
||||
*/
|
||||
if( !(p = strrchr( out, '.' )) ) {
|
||||
im_errormsg( "Bad file name format '%s'", name );
|
||||
free( out );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
/* Read out x posn.
|
||||
*/
|
||||
if( sscanf( p, ".%dx%*d", &n ) != 1 ) {
|
||||
im_errormsg( "Bad file name format '%s'", name );
|
||||
free( out );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
return( n );
|
||||
}
|
||||
|
||||
/* Find the y position of a file name (extract m from <root>.nxm.v).
|
||||
*/
|
||||
static int
|
||||
find_y( name )
|
||||
char *name;
|
||||
{ int m;
|
||||
char *p;
|
||||
char *out = strdup( name );
|
||||
|
||||
/* Chop off '.v'.
|
||||
*/
|
||||
if( !(p = strrchr( out, '.' )) ) {
|
||||
im_errormsg( "Bad file name format '%s'", name );
|
||||
free( out );
|
||||
return( -1 );
|
||||
}
|
||||
*p = '\0';
|
||||
|
||||
/* Find '.nxm'.
|
||||
*/
|
||||
if( !(p = strrchr( out, '.' )) ) {
|
||||
im_errormsg( "Bad file name format '%s'", name );
|
||||
free( out );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
/* Read out y posn.
|
||||
*/
|
||||
if( sscanf( p, ".%*dx%d", &m ) != 1 ) {
|
||||
im_errormsg( "Bad file name format '%s'", name );
|
||||
free( out );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
free( out );
|
||||
return( m );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Join two frames left-right. Have to open them and find their sizes.
|
||||
*/
|
||||
static int
|
||||
join_leftright(IMAGE *left, IMAGE *right, IMAGE *out, int dx, int dy )
|
||||
{
|
||||
|
||||
if (im_lrmerge(left, right, out, dx, dy, 20) == -1){
|
||||
im_errormsg("mergeup: unable to run im_lrmerge");
|
||||
return( -1 );
|
||||
}
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
||||
/* Join two frames up-down. Have to open them and find their sizes.
|
||||
*/
|
||||
static int
|
||||
join_updown( IMAGE *top, IMAGE *bottom, IMAGE *out, int dx, int dy )
|
||||
{
|
||||
if (im_tbmerge(top, bottom, out, dx, dy, 20) == -1){
|
||||
im_errormsg("mergeup: unable to run im_tbmerge");
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
merge_up( int width, int height, IMAGE **inp, IMAGE *outp, int xoff, int yoff,
|
||||
int *hxdisp, int *hydisp, Rect *vrect )
|
||||
{
|
||||
int dx,dy,first_row;
|
||||
int i, j, partial_no, in_no;
|
||||
IMAGE **p_img;
|
||||
char name[29];
|
||||
int v_no, h_no;
|
||||
|
||||
|
||||
|
||||
p_img = (IMAGE **) malloc(1 + 3 * width * height * sizeof(IMAGE *));
|
||||
if( p_img == NULL ){
|
||||
im_errormsg("mergeup: allocation failure in mergeup");
|
||||
return( -1 );
|
||||
}
|
||||
partial_no = 0;
|
||||
v_no = 0;
|
||||
h_no = 0;
|
||||
in_no = 0;
|
||||
first_row = 0;
|
||||
|
||||
if( (width == 0 ) && (height == 0 ) ){
|
||||
im_errormsg("mergeup: Need more than one image");
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
|
||||
for(i=0; i<=height; i++){
|
||||
for(j=0; j<=width; j++){
|
||||
p_img[partial_no] = inp[in_no];
|
||||
++partial_no;
|
||||
if( j != 0 ){
|
||||
im_snprintf( name, 29, "partial_img.%d.v",partial_no );
|
||||
if( !( p_img[partial_no] = im_open( name, "p" )) ){
|
||||
im_errormsg("mergeup: unable to open partial image");
|
||||
free(p_img);
|
||||
return( -1 );
|
||||
}
|
||||
++partial_no;
|
||||
dy = hydisp[h_no ] ;
|
||||
dx = -p_img[partial_no-3]->Xsize + hxdisp[h_no] + xoff ;
|
||||
|
||||
if( (height == 0) && ( j == width) )
|
||||
join_leftright( p_img[partial_no-3],
|
||||
p_img[partial_no-2],outp,dx,dy );
|
||||
else
|
||||
join_leftright( p_img[partial_no-3],
|
||||
p_img[partial_no-2],p_img[partial_no-1],dx,dy );
|
||||
++h_no;
|
||||
}
|
||||
++in_no;
|
||||
}
|
||||
|
||||
if( first_row == 0)
|
||||
first_row = partial_no - 1;
|
||||
|
||||
if( ( i > 0 ) || ( height == 0) ){
|
||||
if( i < height ){
|
||||
im_snprintf( name, 29, "partial_img.%d.v", partial_no );
|
||||
if( !( p_img[partial_no] = im_open( name, "p" )) ){
|
||||
im_errormsg("mergeup: unable to open partial image");
|
||||
free(p_img);
|
||||
return( -1 );
|
||||
}
|
||||
++partial_no;
|
||||
|
||||
dy = -( vrect[v_no].height - p_img[partial_no-2]->Ysize );
|
||||
dx = vrect[v_no].left ;
|
||||
|
||||
++v_no;
|
||||
join_updown( p_img[first_row],
|
||||
p_img[partial_no-2], p_img[partial_no-1],dx,dy );
|
||||
first_row = partial_no-1;
|
||||
}
|
||||
else{
|
||||
dy = -( vrect[v_no].height - p_img[partial_no-1]->Ysize );
|
||||
dx = vrect[v_no].left ;
|
||||
|
||||
join_updown( p_img[first_row], p_img[partial_no-1],outp,dx,dy );
|
||||
}
|
||||
}
|
||||
}
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int
|
||||
main( argc, argv )
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int i, n, j, k;
|
||||
char name[ 1000 ];
|
||||
FILE *fp;
|
||||
char *r;
|
||||
IMAGE *out;
|
||||
int vxdisp[NUM_FILES + 1] ;
|
||||
int vydisp[NUM_FILES + 1] ;
|
||||
int hxdisp[NUM_FILES + 1] ;
|
||||
int hydisp[NUM_FILES + 1] ;
|
||||
Rect hrect[NUM_FILES];
|
||||
Rect vrect[NUM_FILES];
|
||||
|
||||
if( im_init_world( argv[0] ) )
|
||||
error_exit( "unable to start VIPS" );
|
||||
|
||||
/* Too many?
|
||||
*/
|
||||
if( argc > NUM_FILES + 1 )
|
||||
error_exit( "Too many files to merge" );
|
||||
for(i=0; i< NUM_FILES; i++)
|
||||
file_list[i] = 0;
|
||||
/* Too few?
|
||||
*/
|
||||
if( argc == 1 )
|
||||
error_exit( "usage: xoverlap yoverlap file_name output_dir "
|
||||
"<root>.0x0.v <root>.0x1.v ..." );
|
||||
xoverlap = atoi(argv[1]);
|
||||
yoverlap = atoi(argv[2]);
|
||||
fp = fopen( argv[3] , "r" );
|
||||
|
||||
for( i = 5; i < argc; i++ ){
|
||||
/* Find/check root.
|
||||
*/
|
||||
if( !file_root ) {
|
||||
file_root = find_root( argv[i] );
|
||||
if( !file_root )
|
||||
error_exit( "error at file_root" );
|
||||
}
|
||||
else {
|
||||
if( !(r = find_root( argv[i] )) )
|
||||
error_exit( "Error in reading parameters" );
|
||||
if( strcmp( r, file_root ) != 0 )
|
||||
error_exit( "Not all roots identical!" );
|
||||
}
|
||||
|
||||
/* Read out position.
|
||||
*/
|
||||
if( (n = find_x( argv[i] )) < 0 )
|
||||
error_exit( "Error in reading file name" );
|
||||
if( n > width - 1 )
|
||||
width = n;
|
||||
if( (n = find_y( argv[i] )) < 0 )
|
||||
error_exit( "Error in reading file name" );
|
||||
if( n > height - 1 )
|
||||
height = n;
|
||||
|
||||
file_list[n] +=1;
|
||||
}
|
||||
|
||||
/* Make output name. and store them in an array.
|
||||
*/
|
||||
im_snprintf( name, 1000, "%s/paint.hr.v", argv[4] );
|
||||
if( !(out = im_open( name, "w" )) )
|
||||
error_exit("unable to open file for output");
|
||||
|
||||
file_ptr =0;
|
||||
for(i=height; i>=0; i--)
|
||||
for(j=0; j<file_list[i]; j++){
|
||||
im_snprintf( name, 1000, "%s.%dx%d.v", file_root,j,i );
|
||||
output_file = strdup( name );
|
||||
if( !(in[file_ptr] = im_open( output_file, "r" )) )
|
||||
error_exit("unable to open %s for input",output_file);
|
||||
++file_ptr;
|
||||
|
||||
}
|
||||
|
||||
k = 0;
|
||||
for( i=0; i<height; i++ ){
|
||||
for( j=0; j<width; j++ ){
|
||||
if(fscanf(fp,"%d %d ", &hxdisp[k] , &hydisp[k])!=2)
|
||||
error_exit("argh");
|
||||
k++;
|
||||
}
|
||||
if(fscanf(fp,"\n")!=0)
|
||||
error_exit("argh3");
|
||||
}
|
||||
|
||||
for( i=0; i<height; i++ )
|
||||
if(fscanf(fp,"%d %d\n", &vxdisp[i] , &vydisp[i])!=2)
|
||||
error_exit("argh2");
|
||||
|
||||
merge_analysis(width,height,in,xoverlap,yoverlap,vxdisp,vydisp,hxdisp,hydisp,hrect,vrect);
|
||||
merge_up( width, height, in, out, xoverlap, yoverlap, hxdisp, hydisp, vrect );
|
||||
|
||||
for(i=0; i<file_ptr; i++)
|
||||
if( im_close(in[i]) == -1)
|
||||
error_exit("unable to close partial file");
|
||||
if( im_close(out) == -1)
|
||||
error_exit("unable to close\n ");
|
||||
|
||||
return( 0 );
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
bin_PROGRAMS = \
|
||||
cooc \
|
||||
cooc_features \
|
||||
glds \
|
||||
glds_features \
|
||||
simcontr \
|
||||
sines \
|
||||
spatres \
|
||||
squares
|
||||
|
||||
cooc_SOURCES = cooc.c
|
||||
cooc_features_SOURCES = cooc_features.c
|
||||
glds_SOURCES = glds.c
|
||||
glds_features_SOURCES = glds_features.c
|
||||
simcontr_SOURCES = simcontr.c
|
||||
sines_SOURCES = sines.c
|
||||
spatres_SOURCES = spatres.c
|
||||
squares_SOURCES = squares.c
|
||||
|
||||
INCLUDES = -I${top_srcdir}/include @VIPS_CFLAGS@ @VIPS_INCLUDES@
|
||||
AM_LDFLAGS = @LDFLAGS@
|
||||
LDADD = @VIPS_CFLAGS@ ${top_builddir}/libsrc/libvips.la @VIPS_LIBS@
|
||||
|
@ -1,88 +0,0 @@
|
||||
/* @(#) Creates a cooourrence matrix from an image
|
||||
* @(#) Usage: cooc image matrix xpos ypos xsize ysize dx dy flag
|
||||
*
|
||||
* Copyright: 1991, N. Dessipris.
|
||||
*
|
||||
* Author: N. Dessipris
|
||||
* Written on: 26/03/1991
|
||||
* Modified on:
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file is part of VIPS.
|
||||
|
||||
VIPS is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
#include <vips/intl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
IMAGE *image, *matrix;
|
||||
int xpos, ypos, xsize, ysize, dx, dy, flag;
|
||||
|
||||
if (argc != 10)
|
||||
error_exit("Usage:\n\
|
||||
%s image matrix xpos ypos xsize ysize dx dy flag\n\
|
||||
WARNING: The program overwrites the output file if the owner has rw access.",
|
||||
argv[0]);
|
||||
|
||||
if( im_init_world( argv[0] ) )
|
||||
error_exit( "unable to start VIPS" );
|
||||
|
||||
xpos = atoi(argv[3]);
|
||||
ypos = atoi(argv[4]);
|
||||
xsize = atoi(argv[5]);
|
||||
ysize = atoi(argv[6]);
|
||||
dx = atoi(argv[7]);
|
||||
dy = atoi(argv[8]);
|
||||
flag = atoi(argv[9]);
|
||||
|
||||
if ( (image = im_open(argv[1],"r")) == NULL )
|
||||
error_exit("Unable to open %s for input", argv[1]);
|
||||
|
||||
if ( (matrix = im_open(argv[2],"w")) == NULL )
|
||||
error_exit("Unable to open %s for output", argv[2]);
|
||||
|
||||
if ( im_cooc_matrix(image, matrix, xpos, ypos, xsize, ysize,
|
||||
dx, dy, flag) == -1 )
|
||||
error_exit("Unable to im_cooc_matrix");
|
||||
|
||||
if ( im_updatehist(matrix, argv[0], argc - 1, argv + 1) == -1)
|
||||
error_exit("Unable to update history");
|
||||
|
||||
if ( ( im_close( image ) == -1 )||( im_close( matrix ) == -1 ) )
|
||||
error_exit("Unable to close %s or %s",argv[1], argv[2]);
|
||||
|
||||
return(0);
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
/* @(#) Prints features of cooc to stdout
|
||||
* @(#) Usage: cooc_features matrix
|
||||
*
|
||||
* Copyright: 1991, N. Dessipris.
|
||||
*
|
||||
* Author: N. Dessipris
|
||||
* Written on: 26/03/1991
|
||||
* Modified on:
|
||||
* 16/6/93 J.Cupitt
|
||||
* - stupid cooc_features externs removed
|
||||
* - ANSIfied
|
||||
* - print to stdout
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file is part of VIPS.
|
||||
|
||||
VIPS is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
#include <vips/intl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
|
||||
int
|
||||
main( int argc, char *argv[] )
|
||||
{
|
||||
IMAGE *matrix;
|
||||
double fasm, fent, fcor, fcon;
|
||||
|
||||
if( im_init_world( argv[0] ) )
|
||||
error_exit( "unable to start VIPS" );
|
||||
|
||||
if( argc != 2 )
|
||||
error_exit( "usage: %s matrix_image", argv[0] );
|
||||
|
||||
if( !(matrix = im_open(argv[1],"r")) )
|
||||
error_exit( "unable to open %s for input",
|
||||
argv[1] );
|
||||
|
||||
if( im_cooc_asm( matrix, &fasm ) )
|
||||
error_exit( "unable to im_cooc_asm" );
|
||||
|
||||
if( im_cooc_contrast( matrix, &fcon ) )
|
||||
error_exit( "unable to im_cooc_contrast");
|
||||
|
||||
if( im_cooc_entropy( matrix, &fent ) )
|
||||
error_exit( "unable to im_cooc_entropy");
|
||||
|
||||
if( im_cooc_correlation( matrix, &fcor ) )
|
||||
error_exit( "unable to im_cooc_correlation");
|
||||
|
||||
if( im_close( matrix ) )
|
||||
error_exit( "unable to close %s", argv[1]);
|
||||
|
||||
printf( "cooc: ASM=%f, ENT=%f, COR=%f, CON=%f\n",
|
||||
fasm, fent, fcor, fcon);
|
||||
|
||||
return( 0 );
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
/* @(#) Creates a cooourrence matrix from an image
|
||||
* @(#) Usage: glds image matrix xpos ypos xsize ysize dx dy
|
||||
*
|
||||
* Copyright: 1991, N. Dessipris.
|
||||
*
|
||||
* Author: N. Dessipris
|
||||
* Written on: 26/03/1991
|
||||
* Modified on:
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file is part of VIPS.
|
||||
|
||||
VIPS is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
#include <vips/intl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
IMAGE *image, *matrix;
|
||||
int xpos, ypos, xsize, ysize, dx, dy;
|
||||
|
||||
if( im_init_world( argv[0] ) )
|
||||
error_exit( "unable to start VIPS" );
|
||||
|
||||
if (argc != 9)
|
||||
error_exit("Usage:\n\
|
||||
%s image matrix xpos ypos xsize ysize dx dy\n\
|
||||
WARNING: The program overwrites the output file if the owner has rw access.",
|
||||
argv[0]);
|
||||
|
||||
xpos = atoi(argv[3]);
|
||||
ypos = atoi(argv[4]);
|
||||
xsize = atoi(argv[5]);
|
||||
ysize = atoi(argv[6]);
|
||||
dx = atoi(argv[7]);
|
||||
dy = atoi(argv[8]);
|
||||
|
||||
if ( (image = im_open(argv[1],"r")) == NULL )
|
||||
error_exit("Unable to open %s for input", argv[1]);
|
||||
|
||||
if ( (matrix = im_open(argv[2],"w")) == NULL )
|
||||
error_exit("Unable to open %s for output", argv[2]);
|
||||
|
||||
if ( im_glds_matrix(image, matrix, xpos, ypos, xsize, ysize,
|
||||
dx, dy) == -1 )
|
||||
error_exit("Unable to im_glds_matrix");
|
||||
|
||||
if ( im_updatehist(image, argv[0], argc - 1, argv + 1) == -1)
|
||||
error_exit("Unable to update history");
|
||||
|
||||
if ( ( im_close( image ) == -1 )||( im_close( matrix ) == -1 ) )
|
||||
error_exit("Unable to close %s or %s", argv[1], argv[2]);
|
||||
|
||||
return(0);
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
/* @(#) Prints features of glds in stderr
|
||||
* @(#) Usage: glds_features matrix
|
||||
*
|
||||
* Copyright: 1991, N. Dessipris.
|
||||
*
|
||||
* Author: N. Dessipris
|
||||
* Written on: 26/03/1991
|
||||
* Modified on:
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file is part of VIPS.
|
||||
|
||||
VIPS is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
#include <vips/intl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
|
||||
int
|
||||
main( int argc, char *argv[] )
|
||||
{
|
||||
IMAGE *matrix;
|
||||
double fasm, fent, fmean, fcon;
|
||||
|
||||
if( im_init_world( argv[0] ) )
|
||||
error_exit( "unable to start VIPS" );
|
||||
|
||||
if( argc != 2 )
|
||||
error_exit( "usage: %s matrix_image", argv[0] );
|
||||
|
||||
|
||||
if( !(matrix = im_open(argv[1],"r")) )
|
||||
error_exit( "unable to open %s for input",
|
||||
argv[1] );
|
||||
|
||||
if( im_glds_asm( matrix, &fasm ) )
|
||||
error_exit( "unable to im_glds_asm");
|
||||
|
||||
if( im_glds_contrast( matrix, &fcon ) )
|
||||
error_exit( "unable to im_glds_contrast");
|
||||
|
||||
if( im_glds_entropy( matrix, &fent ) )
|
||||
error_exit( "unable to im_glds_entropy");
|
||||
|
||||
if( im_glds_mean( matrix, &fmean ) )
|
||||
error_exit( "unable to im_glds_mean");
|
||||
|
||||
if( im_close( matrix ) )
|
||||
error_exit( "unable to close %s", argv[1]);
|
||||
|
||||
printf( "glds: ASM=%f, ENT=%f, MEAN=%f, CON=%f\n",
|
||||
fasm, fent, fmean, fcon);
|
||||
|
||||
return(0);
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
/* @(#) Creates a pattern showing the simultaneous contrast
|
||||
* @(#) Usage: simcontr file xsize ysize
|
||||
*
|
||||
* Copyright: 1991, N. Dessipris.
|
||||
*
|
||||
* Author: N. Dessipris
|
||||
* Written on: 26/03/1991
|
||||
* Modified on:
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file is part of VIPS.
|
||||
|
||||
VIPS is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
#include <vips/intl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
IMAGE *image;
|
||||
int xsize, ysize;
|
||||
|
||||
if( im_init_world( argv[0] ) )
|
||||
error_exit( "unable to start VIPS" );
|
||||
|
||||
if (argc != 4)
|
||||
error_exit("Usage:\n%s file xsize ysize\n\n\
|
||||
WARNING: The program overwrites the output file if the owner has rw access.",
|
||||
argv[0]);
|
||||
|
||||
xsize = atoi(argv[2]);
|
||||
ysize = atoi(argv[3]);
|
||||
|
||||
|
||||
if ( (image = im_openout(argv[1])) == NULL )
|
||||
error_exit("Unable to open %s for output", argv[1]);
|
||||
|
||||
if ( im_simcontr(image, xsize, ysize) == -1 )
|
||||
error_exit("Unable to im_simcontr");
|
||||
|
||||
if ( im_updatehist(image, argv[0], argc - 1, argv + 1) == -1)
|
||||
error_exit("Unable to update history");
|
||||
|
||||
if ( im_close( image ) == -1 )
|
||||
error_exit("Unable to close %s", argv[1]);
|
||||
|
||||
return(0);
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
/* @(#) Creates a scaled uchar sinewave waveform.
|
||||
* @(#) Usage: sines file xsize ysize horfrew verfreq
|
||||
*
|
||||
* Copyright: 1991, N. Dessipris.
|
||||
*
|
||||
* Author: N. Dessipris
|
||||
* Written on: 26/03/1991
|
||||
* Modified on:
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file is part of VIPS.
|
||||
|
||||
VIPS is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
#include <vips/intl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
IMAGE *image, *bufim;
|
||||
int xsize, ysize;
|
||||
double horfreq, verfreq;
|
||||
|
||||
if( im_init_world( argv[0] ) )
|
||||
error_exit( "unable to start VIPS" );
|
||||
|
||||
if (argc != 6)
|
||||
error_exit("Usage:\n%s file xsize ysize horfreq verfreq\n\n\
|
||||
WARNING: The program overwrites the output file if the owner has rw access.",
|
||||
argv[0]);
|
||||
|
||||
xsize = atoi(argv[2]);
|
||||
ysize = atoi(argv[3]);
|
||||
horfreq = atof(argv[4]);
|
||||
verfreq = atof(argv[5]);
|
||||
|
||||
if ( (bufim = im_setbuf("temp.v")) == NULL )
|
||||
error_exit("Unable to set buffer image");
|
||||
|
||||
if ( im_sines(bufim, xsize, ysize, horfreq, verfreq) == -1 )
|
||||
error_exit("Unable to im_sines");
|
||||
|
||||
if ( (image = im_openout(argv[1])) == NULL )
|
||||
error_exit("Unable to open %s for output", argv[1]);
|
||||
|
||||
if ( im_scale(bufim, image) == -1)
|
||||
error_exit("Unable to im_scale");
|
||||
|
||||
if ( im_updatehist(image, argv[0], argc - 1, argv + 1) == -1)
|
||||
error_exit("Unable to update history");
|
||||
|
||||
if ( ( im_close( image ) == -1 )||( im_close( bufim ) == -1 ) )
|
||||
error_exit("Unable to close %s or buffer image",argv[1]);
|
||||
|
||||
return(0);
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
/* @(#) Reduces the spatial resolution of an image by increasing the
|
||||
* @(#) pixel size
|
||||
* @(#)
|
||||
* @(#) Usage: spatres in out step
|
||||
* @(#)
|
||||
*
|
||||
* Copyright: 1991, N. Dessipris.
|
||||
*
|
||||
* Author: Nicos Dessipris
|
||||
* Written on: 27/03/1991
|
||||
* Modified on :
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file is part of VIPS.
|
||||
|
||||
VIPS is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
#include <vips/intl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
IMAGE *in, *out;
|
||||
int step = 0;
|
||||
|
||||
if( im_init_world( argv[0] ) )
|
||||
error_exit( "unable to start VIPS" );
|
||||
|
||||
if ( (argc != 4)||(argv[1][0] == '-') )
|
||||
error_exit(
|
||||
"Usage:\n%s in out step\n\n\
|
||||
WARNING: The program destroys the opfile if the owner has rw access on it.",
|
||||
argv[0]);
|
||||
|
||||
step = atoi(argv[3]);
|
||||
|
||||
if ((in= im_open(argv[1],"r")) == NULL)
|
||||
error_exit("Unable to open %s for input", argv[1]);
|
||||
|
||||
if ( (out=im_open(argv[2],"w")) == NULL )
|
||||
error_exit("Unable to open %s", argv[2]);
|
||||
|
||||
if ( im_spatres(in, out, step) == -1)
|
||||
error_exit("Unable to im_spatres");
|
||||
|
||||
if ( im_updatehist(out, argv[0], argc - 1, argv + 1) == -1)
|
||||
error_exit("Unable to update history");
|
||||
|
||||
if ( (im_close(in) == -1)||(im_close(out) == -1) )
|
||||
error_exit("unable to close %s or %s",argv[1],argv[2]);
|
||||
|
||||
return(0);
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
/* @(#) Creates a byte square waveform. Binary image with 0 and 255
|
||||
* @(#) Usage: squares file xsize ysize horfreq verfreq
|
||||
*
|
||||
* Copyright: 1991, N. Dessipris.
|
||||
*
|
||||
* Author: N. Dessipris
|
||||
* Written on: 26/03/1991
|
||||
* Modified on:
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file is part of VIPS.
|
||||
|
||||
VIPS is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
#include <vips/intl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
IMAGE *image, *bufim;
|
||||
int xsize, ysize;
|
||||
double horfreq, verfreq;
|
||||
|
||||
if( im_init_world( argv[0] ) )
|
||||
error_exit( "unable to start VIPS" );
|
||||
|
||||
if (argc != 6)
|
||||
error_exit("Usage:\n%s file xsize ysize horfreq verfreq\n\n\
|
||||
WARNING: The program overwrites the output file if the owner has rw access.",
|
||||
argv[0]);
|
||||
|
||||
xsize = atoi(argv[2]);
|
||||
ysize = atoi(argv[3]);
|
||||
horfreq = atof(argv[4]);
|
||||
verfreq = atof(argv[5]);
|
||||
|
||||
if ( (bufim = im_setbuf("temp.v")) == NULL )
|
||||
error_exit("Unable to set buffer image");
|
||||
|
||||
if ( im_sines(bufim, xsize, ysize, horfreq, verfreq) == -1 )
|
||||
error_exit("Unable to im_sines");
|
||||
|
||||
if ( (image = im_openout(argv[1])) == NULL )
|
||||
error_exit("Unable to open %s for output", argv[1]);
|
||||
|
||||
if ( im_thresh(bufim, image, (double)0.0) == -1)
|
||||
error_exit("Unable to im_thresh");
|
||||
|
||||
if ( im_updatehist(image, argv[0], argc - 1, argv + 1) == -1)
|
||||
error_exit("Unable to update history");
|
||||
|
||||
if ( ( im_close( image ) == -1 )||( im_close( bufim ) == -1 ) )
|
||||
error_exit("Unable to close %s or buffer image",
|
||||
argv[1]);
|
||||
|
||||
return(0);
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
bin_SCRIPTS = \
|
||||
light_correct \
|
||||
shrink_width \
|
||||
batch_image_convert \
|
||||
batch_rubber_sheet \
|
||||
batch_crop \
|
||||
vips-7.19
|
||||
|
||||
noinst_SCRIPTS = post_install
|
||||
|
||||
EXTRA_DIST = \
|
||||
vips-7.18 \
|
||||
${noinst_SCRIPTS} \
|
||||
light_correct.in \
|
||||
shrink_width.in \
|
||||
batch_image_convert.in \
|
||||
batch_rubber_sheet.in \
|
||||
batch_crop.in
|
||||
|
||||
install-exec-hook:
|
||||
chmod ugo+x ${DESTDIR}${bindir}/light_correct
|
||||
chmod ugo+x ${DESTDIR}${bindir}/shrink_width
|
||||
chmod ugo+x ${DESTDIR}${bindir}/batch_image_convert
|
||||
chmod ugo+x ${DESTDIR}${bindir}/batch_rubber_sheet
|
||||
chmod ugo+x ${DESTDIR}${bindir}/batch_crop
|
@ -1,45 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Crop a set of image files
|
||||
#
|
||||
# usage:
|
||||
#
|
||||
# example% batch_crop left top width height image1 image2 etc
|
||||
#
|
||||
# writes output images crop_image1, crop_image2
|
||||
|
||||
# default prefix
|
||||
VIPSHOME=${VIPSHOME-@prefix@}
|
||||
|
||||
name=`basename $0`
|
||||
left=$1
|
||||
top=$2
|
||||
width=$3
|
||||
height=$4
|
||||
shift 4
|
||||
|
||||
# check args
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "usage: $name left top width height image1 image2 ..."
|
||||
echo
|
||||
echo "$name writes a new set of images called crop_image1, "
|
||||
echo "crop_image2, etc., each cropped to the specified size"
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# convert each argument
|
||||
for i in $*; do
|
||||
dir=`dirname $i`
|
||||
file=`basename $i`
|
||||
new=$dir/crop_$file
|
||||
echo "Cropping $file as $new ..."
|
||||
|
||||
if [ -f $new ]; then
|
||||
echo "$new exists, skipping"
|
||||
else
|
||||
$VIPSHOME/bin/vips im_extract_area $i $new $left $top $width $height
|
||||
fi
|
||||
done
|
||||
|
||||
|
@ -1,43 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Convert a set of image files to new file format
|
||||
#
|
||||
# usage:
|
||||
#
|
||||
# example% batch_image_convert <new image type> image1 image2 etc
|
||||
#
|
||||
# writes output images image1.* and image2.* where * is the new file type.
|
||||
|
||||
# default prefix
|
||||
VIPSHOME=${VIPSHOME-@prefix@}
|
||||
|
||||
name=`basename $0`
|
||||
type=$1
|
||||
shift
|
||||
|
||||
# check args
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "usage: $name <new image type> image1 image2 ..."
|
||||
echo
|
||||
echo "$name uses VIPS to convert a group of image files of"
|
||||
echo "any image format into a new group of images all of the same"
|
||||
echo "image format. VIPS can read almost any standard image format"
|
||||
echo "but it can only write VIPS, JPEG, TIFF, PPM/PBM/PGM or PNG."
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# convert each argument
|
||||
for i in $*; do
|
||||
# drop the suffix on the filename
|
||||
base=${i%*.*}
|
||||
echo "Converting $i to $base.$type ..."
|
||||
|
||||
if [ -f $base.$type ]; then
|
||||
echo "$base.$type already exists skiping $i"
|
||||
else
|
||||
$VIPSHOME/bin/vips im_copy $i $base.$type
|
||||
fi
|
||||
done
|
||||
|
||||
|
@ -1,38 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Corrects a set of image files for lens distortion using a preprepared
|
||||
# recombination matrix
|
||||
|
||||
# usage:
|
||||
#
|
||||
# example% batch_rubber_sheet matrix_file image1 image2 ..
|
||||
#
|
||||
# writes output images rsc_image1.v, rsc_image2.v ..
|
||||
|
||||
# default prefix
|
||||
VIPSHOME=${VIPSHOME-@prefix@}
|
||||
|
||||
# get name we were run as
|
||||
name=`basename $0`
|
||||
rec=$1
|
||||
shift
|
||||
|
||||
# check args
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "usage: $name matrix image1 image2 ..."
|
||||
echo "writes rsc_image1, rsc_image2, ..."
|
||||
echo
|
||||
echo "$name uses VIPS to correct a set of images for lens distortion"
|
||||
echo "using a matrix calculated by the 'resample' function."
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# transform each argument
|
||||
for i in $*; do
|
||||
echo "Transforming $i to rsc_$i ..."
|
||||
|
||||
# bilinear interp., don't wrap edges
|
||||
$VIPSHOME/bin/vips im_transform $i rsc_$i $rec 1 0
|
||||
done
|
||||
|
@ -1,57 +0,0 @@
|
||||
#!/bin/sh
|
||||
# correct a set of files for illumination errors
|
||||
# usage:
|
||||
#
|
||||
# example% light_correct grey.v im1.v im2.v
|
||||
#
|
||||
# writes output images ic_im1.v and ic_im2.v
|
||||
|
||||
# default prefix
|
||||
VIPSHOME=${VIPSHOME-@prefix@}
|
||||
|
||||
# get name we were run as
|
||||
name=$0
|
||||
bname=`basename $name`
|
||||
|
||||
# names of our temp files
|
||||
t1=light_correct_temp1
|
||||
t2=light_correct_temp2
|
||||
|
||||
# check args
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "${bname}: usage: $bname <grey> <image1> <image2> ..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Preparing grey ..."
|
||||
grey=$1
|
||||
shift
|
||||
|
||||
# find image size
|
||||
width=`$VIPSHOME/bin/vips im_header_int Xsize $grey`
|
||||
height=`$VIPSHOME/bin/vips im_header_int Ysize $grey`
|
||||
|
||||
# smooth the grey out
|
||||
$VIPSHOME/bin/vips im_shrink $grey $t1.v 20 20
|
||||
$VIPSHOME/bin/vips im_resize_linear $t1.v $t2.v $width $height
|
||||
|
||||
# and make the correction image
|
||||
mean=`$VIPSHOME/bin/vips im_avg $t2.v`
|
||||
$VIPSHOME/bin/vips im_powtra $t2.v $t1.v -1
|
||||
$VIPSHOME/bin/vips im_lintra $mean $t1.v 0 $t2.v
|
||||
|
||||
# grey correct images in order
|
||||
for i in "$@"; do
|
||||
echo "Correcting $i as ic_$i ..."
|
||||
$VIPSHOME/bin/vips im_multiply $t2.v "$i" $t1.v
|
||||
$VIPSHOME/bin/vips im_clip $t1.v "ic_$i"
|
||||
|
||||
# remove the .desc as well
|
||||
name=`echo $name | sed -e 's/\.[^\.]*//'`
|
||||
/bin/rm -f "ic_$name.desc"
|
||||
done
|
||||
|
||||
# more cleanup
|
||||
echo "Cleaning up ..."
|
||||
/bin/rm -f $t1.v $t1.desc
|
||||
/bin/rm -f $t2.v $t2.desc
|
@ -1,5 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
bin=$1
|
||||
|
||||
( cd $bin ; $bin/vips -k | sh )
|
@ -1,18 +0,0 @@
|
||||
#!/bin/sh
|
||||
# shrink to a target width
|
||||
|
||||
# default prefix
|
||||
VIPSHOME=${VIPSHOME-@prefix@}
|
||||
|
||||
name=$0
|
||||
bname=`basename $0`
|
||||
|
||||
if [ $# != 3 ]; then
|
||||
echo "${bname}: usage: $bname <in> <out> <target width>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
inwidth=`$VIPSHOME/bin/vips im_header_int Xsize $1`
|
||||
factor=`(echo scale=10; echo $inwidth / $3) | bc`
|
||||
|
||||
$VIPSHOME/bin/vips im_shrink $1 $2 $factor $factor
|
@ -1,116 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Start script for VIPS
|
||||
|
||||
# need extended regexps, hence we insist on bash above
|
||||
shopt -s extglob
|
||||
# set -x
|
||||
|
||||
# name we were invoked as
|
||||
bname=`basename $0`
|
||||
|
||||
# check args
|
||||
if [[ $# < 1 ]]; then
|
||||
echo "usage: $bname [command ...]"
|
||||
echo "examples:"
|
||||
echo " $bname nip"
|
||||
echo " $bname man im_invert"
|
||||
echo " $bname im_invert /pics/tmp/fred.jpg /pics/tmp/fred2.tif"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# try to extract the prefix from a path to an executable
|
||||
# eg. "/home/john/vips/bin/fred" -> "/home/john/vips"
|
||||
function find_prefix () {
|
||||
# try to canonicalise the path
|
||||
ep_canon=$1
|
||||
|
||||
# relative path? prefix with pwd
|
||||
if [ ${ep_canon:0:1} != "/" ]; then
|
||||
ep_canon=`pwd`/$ep_canon
|
||||
fi
|
||||
|
||||
# replace any "/./" with "/"
|
||||
ep_canon=${ep_canon//\/.\//\/}
|
||||
|
||||
# any "xxx/../" can go
|
||||
ep_canon=${ep_canon//+([^\/])\/..\//}
|
||||
|
||||
# trailing "xxx/.." can go
|
||||
ep_canon=${ep_canon/%+([^\/])\/../}
|
||||
|
||||
# remove trailing "/bin/xxx" to get the prefix
|
||||
ep_prefix=${ep_canon/%\/bin\/+([^\/])/}
|
||||
|
||||
# was there anything to remove in that final step? if not, the path
|
||||
# must be wrong
|
||||
if [ x$ep_prefix == x$ep_canon ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo $ep_prefix;
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# try to guess the install prefix from $0
|
||||
function guess_prefix () {
|
||||
# $0 is a file? must be us
|
||||
if [ -f $0 ]; then
|
||||
find_prefix $0
|
||||
return
|
||||
fi
|
||||
|
||||
# nope, extract program name from $0 and try looking along the
|
||||
# searchpath for it
|
||||
name=`basename $0`
|
||||
|
||||
fred=$PATH
|
||||
while [ x$fred != x"" ]; do
|
||||
path=${fred/:*/}/$name
|
||||
fred=${fred/*([^:])?(:)/}
|
||||
|
||||
if [ -f $path ]; then
|
||||
find_prefix $path
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
# not found on path either ... give up!
|
||||
return 1
|
||||
}
|
||||
|
||||
prefix=`guess_prefix`;
|
||||
|
||||
if [ $? != 0 ]; then
|
||||
echo "unable to find $0 from the file name, or from your PATH"
|
||||
echo "either run directly, or add the install bin area to "
|
||||
echo "your PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export VIPSHOME=$prefix
|
||||
|
||||
# add VIPSHOME to man pages
|
||||
export MANPATH=$VIPSHOME/man:$MANPATH
|
||||
|
||||
# add the VIPS lib area to the library path
|
||||
case `uname` in
|
||||
HPUX)
|
||||
export SHLIB_PATH=$VIPSHOME/lib:$SHLIB_PATH
|
||||
;;
|
||||
|
||||
Darwin)
|
||||
export DYLD_LIBRARY_PATH=$VIPSHOME/lib:$DYLD_LIBRARY_PATH
|
||||
;;
|
||||
|
||||
*)
|
||||
export LD_LIBRARY_PATH=$VIPSHOME/lib:$LD_LIBRARY_PATH
|
||||
;;
|
||||
esac
|
||||
|
||||
# add VIPS bin area to path
|
||||
export PATH=$VIPSHOME/bin:$PATH
|
||||
|
||||
# run, passing in args we were passed
|
||||
exec $*
|
Loading…
Reference in New Issue
Block a user