mnhrdt / iio Goto Github PK
View Code? Open in Web Editor NEWa simple C interface for reading and writing small images in any format
License: Other
a simple C interface for reading and writing small images in any format
License: Other
I have a color PNG file that seems normal, but when opened with the iio_read_image_uint8_vec
function, it is read as a 4-band file, which it is not.
Here is the code snippet used showing that iio
reads 4 bands:
int ww, hh, pd;
iio_read_image_uint8_vec("img.png", &ww, &hh, &pd);
printf("%d\n", pd);
/* prints "4" */
and here is the image:
Is something wrong with iio
or with the way it is being used, or is the PNG file weird?
I only need the pgm/ppm io function that's native.
I edited iio.h file so it has no dependencies, at the end:
//#define I_CAN_HAS_LIBPNG
//#define I_CAN_HAS_LIBJPEG
//#define I_CAN_HAS_LIBTIFF
//#define I_CAN_HAS_LIBEXR
I had "Wimplicit-function-declaration" warning when compiling and undefined reference error when linking with this two functions: iio_save_image_as_tiff_smarter and iio_save_image_as_png.
I made a workaround defining and empty function with and #else statement:
#else
static void iio_save_image_as_png(const char *filename, struct iio_image *x)
{
//error
}
#endif//I_CAN_HAS_LIBPNG
And the same with the tiff one
#else
static void iio_save_image_as_tiff_smarter(const char *filename,
struct iio_image *x)
{
//error
}
#endif//I_CAN_HAS_LIBTIFF
Now it works but I dont think this is clean fix. For instance if I compile with Werror the empty definition gives:
error: unused parameter ‘filename’ [-Werror=unused-parameter]
error: unused parameter ‘x’ [-Werror=unused-parameter]
I'm aware the save_image_default function has a "not well designed warning" but maybe a smarter solution is posible.
PS.: with the Werror flag I also get compiling error on 3 functions: unpack_to_bytes_here, iio_fmemopen and swap_two_bytes.
defined but not used [-Werror=unused-function]
a = iio_read('mytiff.tiff')
octave-gui: iio.c :3705 : read_image_f: l'assertion « nbuf > 0 » a échoué.
the tiff was writen with piio.
make test also fails in the octave dir.
Here is the error
piio/libraw_interface.cpp:42:17: error: « IIO_MAX_DIMENSION » n'a pas été déclaré dans cette portée
int sizes[IIO_MAX_DIMENSION];
^~~~~~~~~~~~~~~~~
piio/libraw_interface.cpp:42:17: note: alternatives suggérées: « IP_MAX_MEMBERSHIPS »
int sizes[IIO_MAX_DIMENSION];
^~~~~~~~~~~~~~~~~
IP_MAX_MEMBERSHIPS
piio/libraw_interface.cpp: Dans la fonction « int try_reading_file_with_libraw(const char*, iio_image*) »:
piio/libraw_interface.cpp:120:7: error: « struct iio_image » n'a pas de membre nommé « sizes »
x->sizes[0] = S.raw_width;
^~~~~
piio/libraw_interface.cpp:121:7: error: « struct iio_image » n'a pas de membre nommé « sizes »
x->sizes[1] = S.raw_height;
^~~~~
piio/libraw_interface.cpp: Dans la fonction « int try_reading_file_with_libraw_4channels(const char*, iio_image*) »:
piio/libraw_interface.cpp:196:7: error: « struct iio_image » n'a pas de membre nommé « sizes »
x->sizes[0] = S.iwidth/2;
^~~~~
piio/libraw_interface.cpp:197:7: error: « struct iio_image » n'a pas de membre nommé « sizes »
x->sizes[1] = S.iheight/2;
I had a weird bug with some images badly written.
I discovered what I had saved was in Fortran order,
and piio doesn't care and write as if it was C order.
Thus piio.write should convert the input arrays to C order if necessary.
I used data = np.array(data, order='C')
but it involves a copy, which is not necessary when already in C order.
I think it should work with np.asarray(data, order='C') which should convert only if needed.
If iio requires the data is continuous, numpy.ascontiguousarray converts if needed to C continuous order.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.