Giter Club home page Giter Club logo

cimg's People

Contributors

amyspark avatar apocelipes avatar bkmgit avatar chuvi-w avatar dtschump avatar loongson-zn avatar lrusak avatar mariuszmaximus avatar mighty-professional avatar multiplemonomials avatar poohl avatar xen0n avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cimg's Issues

missing #pragma warning(pop) ?

I was only taking a quick look through the code. I couldn't find a matching #pragma warning(pop) for the opening #pragma warning(push) in line 112. Is that intended?

'_fileno' was not declared in this scope

'_fileno' was not declared in this scope;
At first I was though I needed to stdio.h in other for it to work file , I try it I found is not my problem, but the library issue so decided to passed it.
I have check online if this common problem , I have notice that alot of furum have discussed about it ut none of them actual solved it. When I ignore the line of the code at 4925 in CImg.h it compile okay.

Old versions of library

Hi, Is it possible to also have the old releases of the library hosted here as well, or a pointer to where they can be found? Some codes use these and your interfaces seem to have changed.

Problem loading video on OS X

This error was reported by a user of the imager package, but it's not to do with the R side of things and it has me stumped.
The original issue is here: dahtah/imager#3.
On an OS X system, a call to load() fails on a MPEG-1 video even though the user has installed ffmpeg, imagemagick and graphicsmagick. The video loads fine on all systems I've tried so far (it's here: https://github.com/dahtah/imager/blob/master/inst/extdata/tennis_sif.mpeg)

Here's the CImg error:
convert: delegate failed "ffmpeg" -nostdin -v -1 -i "%i" -vframes %S -vcodec pam -an -f rawvideo -y "%u.pam" 2> "%Z"' @ error/delegate.c/InvokeDelegate/1332. convert: unable to open image/var/tmp/magick-25902iqF0P0m51egQ.pam': No such file or directory @ error/blob.c/OpenBlob/2695.
convert: no images defined `pnm:-' @ error/convert.c/ConvertImageCommand/3230.
sh: mpeg2decode: command not found
gm convert: Unable to open file (/var/folders/70/d3g1lc394k163j9bw8h68f8c0000gn/T/gmtK8MYB*.ppm) [No such file or directory].
gm convert: Unable to open file (/var/folders/70/d3g1lc394k163j9bw8h68f8c0000gn/T/gmh4FOq5).
Error: [instance(0,0,0,0,0x0,non-shared)] CImg::load(): Failed to recognize format of file '/Users/kruny1001/Library/R/3.2/library/imager/extdata/tennis_sif.mpeg'.

Save to bmp file broken.

I've found that save to bmp file is broken in eefe3ce

CImg<float> image("input.bmp");
image.save_bmp("output.bmp");//OK
image.save("output1.bmp");//Some sort of uninitialized variables

hexdump input.bmp

0000000 4d42 00ca 0000 0000 0000 007a 0000 006c
0000010 0000 0005 0000 0005 0000 0001 0018 0000
0000020 0000 0050 0000 0b13 0000 0b13 0000 0000
0000030 0000 0000 0000 4742 7352 0000 0000 0000
0000040 0000 0000 0000 0000 0000 0000 0000 0000
*
0000060 0000 0000 0000 0000 0000 0002 0000 0000
0000070 0000 0000 0000 0000 0000 ffff ffff ffff
0000080 ffff ffff ffff ffff 00ff ffff ffff ffff
*
00000c0 ffff ffff ffff ffff 00ff               
00000ca

hexdump output.bmp - OK

0000000 4d42 0086 0000 0000 0000 0036 0000 0028
0000010 0000 0005 0000 0005 0000 0001 0018 0000
0000020 0000 0050 0000 0100 0000 0100 0000 0000
0000030 0000 0000 0000 ffff ffff ffff ffff ffff
0000040 ffff ffff 00ff ffff ffff ffff ffff ffff
*
0000080 ffff ffff 00ff                         
0000086

hexdump output1.bmp - broken

0000000 4d42 0086 0000 0000 2b98 0e36 7f5d 0028
0000010 0000 0005 0000 0005 0000 0001 0018 0000
0000020 0000 0050 0000 0113 0000 0113 0000 0000
0000030 0000 0000 0000 ffff ffff ffff ffff ffff
0000040 ffff ffff 00ff ffff ffff ffff ffff ffff
*
0000080 ffff ffff 00ff                         
0000086

Problem with libx.so

Hello. I'm building a tool that should work on the machine without X server. The tool just generates some simple colored shapes.
I'm using cmake to build it. The problem that when I', running it on the target machine, it says:
"error while loading shared libraries: libX11.so.6: cannot open shared object file: No such file or directory"
Does that means any tool that use CImg, require X Server installed?
How can I disable libX11.so requirement? I don't use any windows in that tool.

TIF files with if photo == 3 sampleformat == 1 bitspersample == 8 samplesperpixel == 1 not loading correctly

I have a TIF file with
photo == 3
sampleformat == 1
bitspersample == 8
samplesperpixel == 1

which is a colour image but loaded into CImg it is monochrome. I could get it to load correctly by modifying the _load_tiff method to support this case:

The changed code is:

unsigned int spectrum = samplesperpixel;
if (is_spp == false || photo >= 3)
{
spectrum = photo ? 3 : 1;
}

  assign(nx,ny,1,spectrum);

  if (photo >= 3 && sampleformat == 1 && bitspersample == 8 && (samplesperpixel == 1 || samplesperpixel == 3 || samplesperpixel == 4)) {

I can send you the tif file as I can't attach it.

Construct CImg from multiplexed C-style array

In the documentation and the header file, there is a section on the most used methods for constructing a CImg. I think there is an error in the part about constructing images from C-style arrays:

  • CImg img(data_buffer,256,256); constructs a 256x256 greyscale image from a int* buffer data_buffer (of size 256x256=65536).
  • CImg img(data_buffer,256,256,1,3,false); constructs a 256x256 color image from a unsigned char* buffer data_buffer (where R,G,B channels follow each others).
  • CImg img(data_buffer,256,256,1,3,true); constructs a 256x256 color image from a unsigned char* buffer data_buffer (where R,G,B channels are multiplexed).

I think this is wrong as the 6th parameter does not define multiplex yes/no but rather if the CImg is shared or not. At least it always seems to expect non-multiplexed data at all time, right?

I have not found any function to construct a CImg directly from a C-Style array that contains the pixels as interleaved values (RGBRGB...), so I am currently copying the pixels manually in a loop. Recently, I stumbled upon the "load_raw" function that actually allows loading of either multiplexed or serialized pixel data, but only from file, not from memory. Looking into the sources, I saw that in multiplexed mode, it does a copy loop as well, so nothing gained here.

But it probably makes sense to at least correct the documentation (or enlight me in case I misunderstood something).

trying to use CImg to qnx platform

hi,

i want to downscale my image(format = png). i found CImg and tried to use it for downscaling my image.
it is giving me linker error for gdi32. i can link it on my desktop, but my target machine is a hardware which has QNX operating system. So, my question is, is it possible to use this library for qnx?
if yes, please guide me for the same.
Development environment:

  1. i am using qt creator as an IDE, and MinGW compiler(it is default with qt but it doesnt have gdi32 library)
    Or if you have anyother suggestion which can help me achieve my goal, please do direct me in that direction, i would be very grateful. please help its a little urgent.

thanks and regards

Visual Studio 2015 - CImage reference error

Hi,

Trying to execute a sample given in "Tutorials" section using visual studio 2015/ C++ project.
Getting the "CImg.h" not found even though I have copied the CImg.h to header file folder in project.
Please explain the steps to run the sample example in visual studio 2015/2013.

Abandoned members

I have found that I can not use image.dimx() and visu.display() any more.
How can I know that some members has been abandoned ? And how can I get the members that have the same function?

Change Log request

I would find interesting to have a short summary of the main changes in CImg.h when a new stable version is released.
This way people could figure out if it is interesting for them to upgrade wait until a new release.

Thanks in advance

Can't load JPG

Hello!
I know it's a recurent issue, but I didn't find the way to solve this one.
So I have my code :
int main(int argc, char** argv){ cimg_library::CImg<unsigned char> ImgIn ("1.jpg") }
And I have the error "failed to open 1.jpg". I have ImageMagick, I first downloaded it to E:\ so I used cimg::imagemagick_path("E:\\ImageMagick-6.9.3-Q16\\convert.exe");
But it didn't work, so I had unistall it and reinstall in "C:\Program\ImageMagick".
Nothing more happened.
Each tim I tried to use absolute path instead of relative, but it never succeed. Do you have any suggestions for me?

Thanks a lot!

Open big raw, analyze and nifti files fail

Hi everyone,

When trying to load a large raw file, I've got very strange behaviour, only the n first slice are loaded, the rest is empty (0 value). All is fine with smaller files.

I tried to get the minimal code producing error, but I obtained something different: at a certain image size, the file is not load at all (16GB for me), see http://pastebin.com/VxEfe3KF

Do you have any idea ?

Won't build on Mac

Environment: Mac OS 10.10.3 (Yosemite) with X11 (XQuartz) installed, working, and linked in /opt/X11. I'm using g++ (clang).

Steps to reproduce: Clone github, attempt to compile /examples/CImg_demo.cpp using g++.

Expected results: Successful compilation.

Actual results: Build fails, shows the following error:

Undefined symbols for architecture x86_64:
  "_XAllocClassHint", referenced from:
      cimg_library::CImgDisplay::_assign(unsigned int, unsigned int, char const*, unsigned int, bool, bool) in readJpeg-49dd1e.o
  "_XCheckMaskEvent", referenced from:
      cimg_library::CImgDisplay::_events_thread(void*) in readJpeg-49dd1e.o
  "_XCheckTypedEvent", referenced from:
      cimg_library::CImgDisplay::_events_thread(void*) in readJpeg-49dd1e.o
  "_XCheckWindowEvent", referenced from:
      cimg_library::CImgDisplay::_handle_events(_XEvent const*) in readJpeg-49dd1e.o
  "_XCloseDisplay", referenced from:
      cimg_library::CImgDisplay::screen_width() in readJpeg-49dd1e.o
      cimg_library::CImgDisplay::screen_height() in readJpeg-49dd1e.o
  "_XCreateColormap", referenced from:
      cimg_library::CImgDisplay::_assign(unsigned int, unsigned int, char const*, unsigned int, bool, bool) in readJpeg-49dd1e.o
  "_XCreateImage", referenced from:
      void cimg_library::CImgDisplay::_resize<unsigned char>(unsigned char, unsigned int, unsigned int, bool) in readJpeg-49dd1e.o
      void cimg_library::CImgDisplay::_resize<unsigned short>(unsigned short, unsigned int, unsigned int, bool) in readJpeg-49dd1e.o
      void cimg_library::CImgDisplay::_resize<unsigned int>(unsigned int, unsigned int, unsigned int, bool) in readJpeg-49dd1e.o
      cimg_library::CImgDisplay::_assign(unsigned int, unsigned int, char const*, unsigned int, bool, bool) in readJpeg-49dd1e.o
      cimg_library::CImgDisplay::_init_fullscreen() in readJpeg-49dd1e.o
  "_XCreateSimpleWindow", referenced from:
      cimg_library::CImgDisplay::_assign(unsigned int, unsigned int, char const*, unsigned int, bool, bool) in readJpeg-49dd1e.o
  "_XCreateWindow", referenced from:
      cimg_library::CImgDisplay::_assign(unsigned int, unsigned int, char const*, unsigned int, bool, bool) in readJpeg-49dd1e.o
      cimg_library::CImgDisplay::_init_fullscreen() in readJpeg-49dd1e.o
  "_XDestroyWindow", referenced from:
      cimg_library::CImgDisplay::assign() in readJpeg-49dd1e.o
      cimg_library::CImgDisplay::_desinit_fullscreen() in readJpeg-49dd1e.o
  "_XFree", referenced from:
      cimg_library::CImgDisplay::_assign(unsigned int, unsigned int, char const*, unsigned int, bool, bool) in readJpeg-49dd1e.o
  "_XFreeColormap", referenced from:
      cimg_library::CImgDisplay::assign() in readJpeg-49dd1e.o
  "_XGetVisualInfo", referenced from:
      cimg_library::CImgDisplay::_assign(unsigned int, unsigned int, char const*, unsigned int, bool, bool) in readJpeg-49dd1e.o
  "_XGetWindowAttributes", referenced from:
      cimg_library::CImgDisplay::resize(int, int, bool) in readJpeg-49dd1e.o
      cimg_library::CImgDisplay::_init_fullscreen() in readJpeg-49dd1e.o
      cimg_library::CImgDisplay::_map_window() in readJpeg-49dd1e.o
      cimg_library::CImgDisplay::_handle_events(_XEvent const*) in readJpeg-49dd1e.o
  "_XGrabKeyboard", referenced from:
      cimg_library::CImgDisplay::_assign(unsigned int, unsigned int, char const*, unsigned int, bool, bool) in readJpeg-49dd1e.o
  "_XInternAtom", referenced from:
      cimg_library::CImgDisplay::_assign(unsigned int, unsigned int, char const*, unsigned int, bool, bool) in readJpeg-49dd1e.o
  "_XLookupString", referenced from:
      cimg_library::CImgDisplay::_handle_events(_XEvent const*) in readJpeg-49dd1e.o
  "_XMapRaised", referenced from:
      cimg_library::CImgDisplay::_init_fullscreen() in readJpeg-49dd1e.o
      cimg_library::CImgDisplay::_map_window() in readJpeg-49dd1e.o
  "_XMoveWindow", referenced from:
      cimg_library::CImgDisplay::move(int, int) in readJpeg-49dd1e.o
  "_XOpenDisplay", referenced from:
      cimg_library::CImgDisplay::screen_width() in readJpeg-49dd1e.o
      cimg_library::CImgDisplay::screen_height() in readJpeg-49dd1e.o
      cimg_library::CImgDisplay::_assign(unsigned int, unsigned int, char const*, unsigned int, bool, bool) in readJpeg-49dd1e.o
  "_XPutImage", referenced from:
      cimg_library::CImgDisplay::_paint(bool) in readJpeg-49dd1e.o
      cimg_library::CImgDisplay::_init_fullscreen() in readJpeg-49dd1e.o
  "_XQueryKeymap", referenced from:
      cimg_library::CImgDisplay::_handle_events(_XEvent const*) in readJpeg-49dd1e.o
  "_XResizeWindow", referenced from:
      cimg_library::CImgDisplay::resize(int, int, bool) in readJpeg-49dd1e.o
      cimg_library::CImgDisplay::_handle_events(_XEvent const*) in readJpeg-49dd1e.o
  "_XSelectInput", referenced from:
      cimg_library::CImgDisplay::_assign(unsigned int, unsigned int, char const*, unsigned int, bool, bool) in readJpeg-49dd1e.o
      cimg_library::CImgDisplay::_init_fullscreen() in readJpeg-49dd1e.o
  "_XSendEvent", referenced from:
      cimg_library::CImgDisplay::_paint(bool) in readJpeg-49dd1e.o
  "_XSetClassHint", referenced from:
      cimg_library::CImgDisplay::_assign(unsigned int, unsigned int, char const*, unsigned int, bool, bool) in readJpeg-49dd1e.o
  "_XSetInputFocus", referenced from:
      cimg_library::CImgDisplay::_handle_events(_XEvent const*) in readJpeg-49dd1e.o
  "_XSetWMProtocols", referenced from:
      cimg_library::CImgDisplay::_assign(unsigned int, unsigned int, char const*, unsigned int, bool, bool) in readJpeg-49dd1e.o
  "_XSetWindowColormap", referenced from:
      cimg_library::CImgDisplay::_assign(unsigned int, unsigned int, char const*, unsigned int, bool, bool) in readJpeg-49dd1e.o
  "_XStoreColors", referenced from:
      cimg_library::CImgDisplay::_set_colormap(unsigned long&, unsigned int) in readJpeg-49dd1e.o
  "_XStoreName", referenced from:
      cimg_library::CImgDisplay::_assign(unsigned int, unsigned int, char const*, unsigned int, bool, bool) in readJpeg-49dd1e.o
  "_XSync", referenced from:
      cimg_library::CImgDisplay::assign() in readJpeg-49dd1e.o
      cimg_library::CImgDisplay::_init_fullscreen() in readJpeg-49dd1e.o
      cimg_library::CImgDisplay::_map_window() in readJpeg-49dd1e.o
      cimg_library::CImgDisplay::_handle_events(_XEvent const*) in readJpeg-49dd1e.o
  "_XUngrabKeyboard", referenced from:
      cimg_library::CImgDisplay::_desinit_fullscreen() in readJpeg-49dd1e.o
  "_XUnmapWindow", referenced from:
      cimg_library::CImgDisplay::_handle_events(_XEvent const*) in readJpeg-49dd1e.o
  "_XVisualIDFromVisual", referenced from:
      cimg_library::CImgDisplay::_assign(unsigned int, unsigned int, char const*, unsigned int, bool, bool) in readJpeg-49dd1e.o
  "_XWindowEvent", referenced from:
      cimg_library::CImgDisplay::_init_fullscreen() in readJpeg-49dd1e.o
      cimg_library::CImgDisplay::_map_window() in readJpeg-49dd1e.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

It compiles successfully if I set "cimg_display" to 0 for my OS, (Line 205) however I don't believe this is a fix.

Modification of Voxel values using load_medcon_external fonction to load DICOM data

I tried to load a dicom image on my c++ program using this library but after validation voxel values has been modified. The range of the loaded image was {0,2800} instead of {-1000,2000}.
I did not found where the modification of the value is done. Indeed medcon program do not modify the voxel values.
Does anybody have an idee to load DICOM data without modification on a c++ program? The range of the voxel values is very important for medical analysis.

Thanks

Haar()

Im working with bmp images, i convert the image in gray scale image, call haar() y thrown exception : [instance(258,204,1,1,027B0068, non-shared)] Cimg::haar(): Sub-image width 129 is not even. Some image not thrown this exception, why?

Rotate & Crop an image takes a lot of time

Hello and thanks for a great library!

So, the issue is - I'm trying to crop a rotated rectangle from an image, therefore I use this code:

CImg<unsigned char> image;
image.assign(file_source_path);
image.rotate(angle, 0, 0).crop(left, top, left + width, top + height).save(file_result_path);

The result is correct, but it takes more than 20 seconds to crop 1000x1000 px region from 4000x5600 px jpeg image. I was also trying to pass different parameters to rotate function, but the nearest type of interpolation seems to be the fastest (linear & cubic took up to 40 seconds). Same for boundary conditions.

However when I'm using OpenCV library to perform the same task with the same image, it takes just 2±1 seconds.

Example code:

Mat src = imread(file_source_path, CV_LOAD_IMAGE_UNCHANGED);
Point2f center(src.cols/2.0, src.rows/2.0);
Mat rot = getRotationMatrix2D(center, angle, 1.0);
Rect bbox = RotatedRect(center,src.size(), angle).boundingRect();
rot.at<double>(0,2) += bbox.width/2.0 - center.x;
rot.at<double>(1,2) += bbox.height/2.0 - center.y;

Mat dst;
warpAffine(src, dst, rot, bbox.size());
Rect myROI(left, top, width, height);
Mat croppedImage = dst(myROI);

imwrite(file_result_path, croppedImage, vector<int>({CV_IMWRITE_JPEG_QUALITY, 80}));

But I don't want to include OpenCV into my project, you library seems to have everything that I need and still very small.

So the question is, am I doing something wrong? Can I optimize the time for such operation and how? Thanks in advance.

Loading a jpeg image can leak the open file descriptor.

Loading a jpeg (via libjpeg) basically does this:

struct jpeg_decompress_struct cinfo;
if (setjmp(jerr.setjmp_buffer)) { // JPEG error
    throw CImgIOException( ... jerr.message ... );
}

std::FILE *const nfile = file?file:cimg::fopen(filename,"rb");

jpeg_create_decompress(&cinfo);
// many calls to jpeg functions
CImg<ucharT> buffer(cinfo.output_width*cinfo.output_components);
assign(cinfo.output_width,cinfo.output_height,1,cinfo.output_components);
// more calls to jpeg functions

If some libjpeg function after setjmp fails, execution jumps back to setjmp, goes into the branch and throws the exception. The opened file is not closed and the FILE pointer nfile is effectively lost and never closed. This can probably be triggered by a faulty image file.

Similar leak happens when buffer is created and can not allocate enough memory. It throws from operator new, but nfile is not closed. The same happens when assign is called (which allocates memory for the whole image) and it fails to allocate the memory.

The issues can be triggered when a program has already allocated nearly all available (virtual) memory and tries to load a huge (according to its dimensions) image. Either allocation inside of libjpeg fails and jumps back to setjmp, or the constructor of buffer / call to assign fails and throws. Those exceptions were caught by my program and execution continued as it should. But later, any attempt to open a file failed because the program had reached the maximal amount of open file handles.

There may be other calls in that function that can throw.


Suggestion to solve the issue:

  1. Move the opening the file (and definition of nfile) before the call to setjmp and close the file (if needed) in the branch right before throwing (fixes leak when libjpeg jumps back).
  2. Add a simple wrapper class that automatically closes the file handle and create an instance of that class on the stack. (Maybe just std::unique_ptr with a specific deleter function that calls fclose.) This would close the file automatically upon any throwing (fixes leak from throwing constructor).

_load_png seems handle the setjmp related issue correctly (it closes the file when setjmp returns true). However, it contains a few calls to new, which may throw, and will not close the file when that happens. So there is a leak as well.

save_tiff() having issues on 32 bit computer

save_tiff() function when used with the cimg_use_tiff directive, ends up in writing an incorrect file format on 32 bit machines. When the file is opened in a tool like ImageJ, gives an error that the file is not in supported format. However it is working on a 64 bit machine.

I am not sure what the cause of the problem is. Kindly help resolve the issue.

Typo

Hey, you don't have a contributing.md so I was unsure how to suggest corrections.

Line 2079 has:

// necessary stuffs to ensure a correct declaration order of the classes and functions

Should be stuff (not stuffs).

Very well written library, learned a lot reading it - still not done (y)

What is the C++ code to obtain gray scale image pixel intensity values using CImg library ?

Hi, everyone I’m a beginner to C++ and raspberrypi, Here I’m working on a project to capture the real time images using Raspberrypi CSI camera and to perform simple image processing operation in C++ using CImg library.

That is, to detect the bright spot in an image (such as LED light glow) and if detects the bright spot, output should be given as ‘1’ and if not (when the LED is off ) output should be given as ‘0’.

Note: The image processing has to be done only in the specific portion of an image (i.e focus only on the led section of an image and neglecting remaining portion of an image which is out of interest, such that it saves processing time and improves performance)

But firstly I don’t know how to get pixel intensity values of a gray scale image using CImg library such that we can compare the values obtained in the pixel to the threshold value and problem could be solved ( this is my algorithm for the above operation but any other simpler methods for the above processing ,your suggestions are always welcome )

Could you help me in a C++ code or algorithm to perform the above task.
Thanks in advance.

undefined reference

Hello experts,
I just tried to include CImg in my code, however, I had the undefine reference error.
First I downloaded CImg from website and unpacked.
In my code i included

include "CImg.h"

using namespace cimg_library;

And then compiled by cmake. it appears hundreds of error like :

CMakeFiles/test1.dir/test1.cpp.o: In function cimg_library::cimg::X11_info::X11_info()': /usr/include/CImg.h:2526: undefined reference toXInitThreads'
CMakeFiles/test1.dir/test1.cpp.o: In function cimg_library::cimg::X11_info::~X11_info()': /usr/include/CImg.h:2541: undefined reference toXCloseDisplay'
CMakeFiles/test1.dir/test1.cpp.o: In function `cimg_library::CImgDisplay::screen_width()':

And the sumary is

collect2: error: ld returned 1 exit status
make[3]: *** [test/test1] Error 1
make[2]: *** [test/CMakeFiles/test1.dir/all] Error 2
make[1]: *** [test/CMakeFiles/test1.dir/rule] Error 2
make: *** [test/CMakeFiles/test1.dir/rule] Error 2

I found some others also have the same problem, but their solution require to provide link every compilation with g++.(and it does not work for my case).
I installed cimg-dev from ubuntu repository but, everything is still the same.

I also use Eclipse, and the GNU tool chains kit does not detect any undefined indexer (I added path to CImg folder). But it could not be compiled.

Could you please tell me what to do?
Thank you very much.

How to do canny edge detection

I found this library and quite liked it because of its simplicity. However, I need to implement canny edge detection (or any kind of edge detection/shape detection) on a very simple image of a black blob. The image will be 100% black and white (not grayscale) and there will be only one black area.

How would I go about doing this?

CImg.h not work in Universal Windwos Platform (uwp).

I'm trying to make a universal windows platform project using CImg but, Once I include the CImg.h and build generate this output.

1>------ Rebuild All started: Project: WindowsRuntimeComponent1, Configuration: Debug Win32 ------
1> pch.cpp
1> Class1.cpp
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4048): error C2065: 'PROCESS_INFORMATION': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4048): error C2146: syntax error: missing ';' before identifier 'pi'
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4048): error C2065: 'pi': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4049): error C2065: 'STARTUPINFO': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4049): error C2146: syntax error: missing ';' before identifier 'si'
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4049): error C2065: 'si': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4050): error C2065: 'pi': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4050): error C2065: 'PROCESS_INFORMATION': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4051): error C2065: 'si': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4051): error C2065: 'STARTUPINFO': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4052): error C2065: 'si': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4052): error C3861: 'GetStartupInfo': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4053): error C2065: 'si': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4053): error C2228: left of '.cb' must have class/struct/union
1> c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4053): note: type is 'unknown-type'
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4054): error C2065: 'si': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4054): error C2228: left of '.wShowWindow' must have class/struct/union
1> c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4054): note: type is 'unknown-type'
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4055): error C2065: 'si': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4055): error C2228: left of '.dwFlags' must have class/struct/union
1> c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4055): note: type is 'unknown-type'
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4055): error C2065: 'STARTF_USESHOWWINDOW': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4056): error C2065: 'si': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4056): error C2065: 'pi': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4056): error C3861: 'CreateProcess': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4058): error C2065: 'pi': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4058): error C2228: left of '.hProcess' must have class/struct/union
1> c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4058): note: type is 'unknown-type'
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4059): error C2065: 'pi': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4059): error C2228: left of '.hThread' must have class/struct/union
1> c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4059): note: type is 'unknown-type'
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4060): error C2065: 'pi': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4060): error C2228: left of '.hProcess' must have class/struct/union
1> c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4060): note: type is 'unknown-type'
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4062): error C2039: 'system': is not a member of 'std'
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\ctime(17): note: see declaration of 'std'
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4313): error C3861: '_getpid': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4811): error C3861: 'GetShortPathNameA': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4871): error C3861: 'GetFileAttributesA': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(4900): error C3861: 'CreateFileA': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8298): error C3646: '_ccs': unknown override specifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8298): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8308): error C2065: 'ENUM_CURRENT_SETTINGS': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8308): error C3861: 'EnumDisplaySettings': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8316): error C2065: 'ENUM_CURRENT_SETTINGS': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8316): error C3861: 'EnumDisplaySettings': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8328): error C3861: 'GetWindowLong': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8337): error C3861: 'ShowWindow': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8342): error C3861: 'PeekMessage': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8355): error C3861: 'PeekMessage': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8369): error C3861: 'ShowCursor': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8384): error C3861: 'PeekMessage': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8389): error C2065: 'TRACKMOUSEEVENT': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8389): error C2146: syntax error: missing ';' before identifier 'tme'
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8389): error C2065: 'tme': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8390): error C2065: 'tme': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8390): error C2228: left of '.cbSize' must have class/struct/union
1> c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8390): note: type is 'unknown-type'
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8390): error C2065: 'TRACKMOUSEEVENT': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8391): error C2065: 'tme': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8391): error C2228: left of '.dwFlags' must have class/struct/union
1> c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8391): note: type is 'unknown-type'
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8392): error C2065: 'tme': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8392): error C2228: left of '.hwndTrack' must have class/struct/union
1> c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8392): note: type is 'unknown-type'
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8393): error C2065: 'tme': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8393): error C3861: 'TrackMouseEvent': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8401): error C3861: 'ShowCursor': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8408): error C3861: 'ShowCursor': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8439): error C3861: 'DefWindowProc': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8462): error C3861: 'AdjustWindowRect': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8466): error C2039: '_ccs': is not a member of 'cimg_library::CImgDisplay'
1> c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(5639): note: see declaration of 'cimg_library::CImgDisplay'
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8466): error C3861: 'CreateWindowExA': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8471): error C3861: 'GetWindowRect': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8479): error C2039: '_ccs': is not a member of 'cimg_library::CImgDisplay'
1> c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(5639): note: see declaration of 'cimg_library::CImgDisplay'
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8479): error C3861: 'CreateWindowExA': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8486): error C3861: 'SetForegroundWindow': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8487): error C3861: 'GetDC': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8495): error C3861: 'SetWindowLong': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8496): error C3861: 'SetWindowLong': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8499): error C3861: 'GetMessage': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8499): error C3861: 'DispatchMessage': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8508): error C3861: 'AdjustWindowRect': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8512): error C3861: 'GetWindowRect': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8525): error C3861: 'EnumDisplaySettings': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8535): error C2065: 'ENUM_CURRENT_SETTINGS': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8535): error C3861: 'EnumDisplaySettings': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8536): error C3861: 'EnumDisplaySettings': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8537): error C3861: 'ChangeDisplaySettings': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8544): error C2065: 'CLIENTCREATESTRUCT': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8544): error C2146: syntax error: missing ';' before identifier 'background_ccs'
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8544): error C2065: 'background_ccs': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8545): error C2065: 'background_ccs': undeclared identifier
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8545): error C3861: 'CreateWindowExA': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8546): error C3861: 'SetForegroundWindow': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8553): error C3861: 'DestroyWindow': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8555): error C3861: 'ChangeDisplaySettings': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8598): error C3861: 'DestroyWindow': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8599): error C3861: 'TerminateThread': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8671): error C3861: 'AdjustWindowRect': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8673): error C3861: 'SetWindowPos': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8715): error C3861: 'ShowWindow': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8724): error C3861: 'ShowWindow': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8735): error C3861: 'AdjustWindowRect': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8739): error C3861: 'SetWindowPos': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8740): error C3861: 'SetWindowPos': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8764): error C3861: 'SetCursorPos': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8781): error C3861: 'SetWindowTextA': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(8799): error C3861: 'SetDIBitsToDevice': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(51312): error C2039: 'getenv': is not a member of 'std'
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\ctime(17): note: see declaration of 'std'
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(51312): error C3861: 'getenv': identifier not found
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(51313): error C2039: 'getenv': is not a member of 'std'
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\ctime(17): note: see declaration of 'std'
1>c:\users\leo03\documents\visual studio 2015\projects\windowsruntimecomponent1\windowsruntimecomponent1\cimg.h(51313): fatal error C1003: error count exceeds 100; stopping compilation
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

Link with sample project with this error

https://onedrive.live.com/redir?resid=F5669F7C478D4DD9!2546&authkey=!AA28XZfHiq0eHqU&ithint=file%2czip

multithreaded filtering function in CImg

Hello,
I would like to know if there is a simple way to get multithreaded filtering function in CImg. I tried to modify CImg loop macros with openmp pragma instructions without succes...
Best regards,

Misleading argument name in blur_box

The argument that indicates the size of the box filter is called "sigma".
In my opinion this is a bit confusing since it is a size (expressed in pixels if positive and relative to the image dimensions if negative).
Something like box_size would provide a better idea of the meaning of the argument

Undefined symbols for architecture x86_64

Hi, I tried to compile one of the examples on mac os x 10.11, but i got below error.
$ g++ -o main captcha.cpp
Undefined symbols for architecture x86_64:
"_XAllocClassHint", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XCheckMaskEvent", referenced from:
cimg_library::CImgDisplay::events_thread(void) in captcha-e2d6a3.o
"_XCheckTypedEvent", referenced from:
cimg_library::CImgDisplay::events_thread(void) in captcha-e2d6a3.o
"_XCheckWindowEvent", referenced from:
cimg_library::CImgDisplay::_handle_events(XEvent const) in captcha-e2d6a3.o
"_XCloseDisplay", referenced from:
cimg_library::CImgDisplay::screen_width() in captcha-e2d6a3.o
cimg_library::CImgDisplay::screen_height() in captcha-e2d6a3.o
"_XCreateColormap", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XCreateImage", referenced from:
void cimg_library::CImgDisplay::_resize(unsigned char, unsigned int, unsigned int, bool) in captcha-e2d6a3.o
void cimg_library::CImgDisplay::_resize(unsigned short, unsigned int, unsigned int, bool) in captcha-e2d6a3.o
void cimg_library::CImgDisplay::_resize(unsigned int, unsigned int, unsigned int, bool) in captcha-e2d6a3.o
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
cimg_library::CImgDisplay::_init_fullscreen() in captcha-e2d6a3.o
"_XCreateSimpleWindow", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XCreateWindow", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
cimg_library::CImgDisplay::_init_fullscreen() in captcha-e2d6a3.o
"_XDestroyWindow", referenced from:
cimg_library::CImgDisplay::assign() in captcha-e2d6a3.o
cimg_library::CImgDisplay::_desinit_fullscreen() in captcha-e2d6a3.o
"_XFree", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XFreeColormap", referenced from:
cimg_library::CImgDisplay::assign() in captcha-e2d6a3.o
"_XGetVisualInfo", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XGetWindowAttributes", referenced from:
cimg_library::CImgDisplay::resize(int, int, bool) in captcha-e2d6a3.o
cimg_library::CImgDisplay::_init_fullscreen() in captcha-e2d6a3.o
cimg_library::CImgDisplay::_map_window() in captcha-e2d6a3.o
cimg_library::CImgDisplay::_handle_events(XEvent const) in captcha-e2d6a3.o
"_XGrabKeyboard", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XInternAtom", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XLookupString", referenced from:
cimg_library::CImgDisplay::_handle_events(XEvent const) in captcha-e2d6a3.o
"_XMapRaised", referenced from:
cimg_library::CImgDisplay::_init_fullscreen() in captcha-e2d6a3.o
cimg_library::CImgDisplay::_map_window() in captcha-e2d6a3.o
"_XMoveWindow", referenced from:
cimg_library::CImgDisplay::move(int, int) in captcha-e2d6a3.o
"_XOpenDisplay", referenced from:
cimg_library::CImgDisplay::screen_width() in captcha-e2d6a3.o
cimg_library::CImgDisplay::screen_height() in captcha-e2d6a3.o
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XPutImage", referenced from:
cimg_library::CImgDisplay::_init_fullscreen() in captcha-e2d6a3.o
cimg_library::CImgDisplay::_paint(bool) in captcha-e2d6a3.o
"_XQueryKeymap", referenced from:
cimg_library::CImgDisplay::_handle_events(XEvent const) in captcha-e2d6a3.o
"_XResizeWindow", referenced from:
cimg_library::CImgDisplay::resize(int, int, bool) in captcha-e2d6a3.o
cimg_library::CImgDisplay::_handle_events(XEvent const) in captcha-e2d6a3.o
"_XSelectInput", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
cimg_library::CImgDisplay::_init_fullscreen() in captcha-e2d6a3.o
"_XSendEvent", referenced from:
cimg_library::CImgDisplay::_paint(bool) in captcha-e2d6a3.o
"_XSetClassHint", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XSetInputFocus", referenced from:
cimg_library::CImgDisplay::_handle_events(XEvent const) in captcha-e2d6a3.o
"_XSetWMProtocols", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XSetWindowColormap", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XStoreColors", referenced from:
cimg_library::CImgDisplay::_set_colormap(unsigned long&, unsigned int) in captcha-e2d6a3.o
"_XStoreName", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XSync", referenced from:
cimg_library::CImgDisplay::assign() in captcha-e2d6a3.o
cimg_library::CImgDisplay::_init_fullscreen() in captcha-e2d6a3.o
cimg_library::CImgDisplay::_map_window() in captcha-e2d6a3.o
cimg_library::CImgDisplay::_handle_events(XEvent const) in captcha-e2d6a3.o
"_XUngrabKeyboard", referenced from:
cimg_library::CImgDisplay::_desinit_fullscreen() in captcha-e2d6a3.o
"_XUnmapWindow", referenced from:
cimg_library::CImgDisplay::_handle_events(XEvent const) in captcha-e2d6a3.o
"_XVisualIDFromVisual", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XWindowEvent", referenced from:
cimg_library::CImgDisplay::_init_fullscreen() in captcha-e2d6a3.o
cimg_library::CImgDisplay::_map_window() in captcha-e2d6a3.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

cimg on windows7

This is probably a reflection of my unfamiliarity with Windows. For some reason I'm trying to compile a program using CImg on Windows7. The errors I get sort of seem like I'm missing some library, but I really have no clue. Any help would be appreciated.

The first few lines of errors look like this:
In file included from grey.cpp:9:0:
CImg.h: In function 'char* cimg_library::cimg::number_filename(const char_, int, unsigned int, char_)':
CImg.h:144:23: error: 'snprintf' is not a member of 'std'
#define cimg_snprintf std::snprintf
^
CImg.h:4961:17: note: in expansion of macro 'cimg_snprintf'
if (ext) cimg_snprintf(format,1024,"%%s%%.%ud.%%s",digits);
^
CImg.h:144:23: note: suggested alternative:
#define cimg_snprintf std::snprintf
^
CImg.h:4961:17: note: in expansion of macro 'cimg_snprintf'
if (ext) cimg_snprintf(format,1024,"%%s%%.%ud.%%s",digits);
^
In file included from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\cstdio:42:0,
from CImg.h:73,
from grey.cpp:9:
c:\mingw\include\stdio.h:317:29: note: 'snprintf'
int __cdecl _MINGW_NOTHROW snprintf (char *, size_t, const char *, ...);
^
In file included from grey.cpp:9:0:
CImg.h:144:23: error: 'snprintf' is not a member of 'std'
#define cimg_snprintf std::snprintf
^
CImg.h:4962:12: note: in expansion of macro 'cimg_snprintf'
else cimg_snprintf(format,1024,"%%s
%%.%ud",digits);
^
CImg.h:144:23: note: suggested alternative:
#define cimg_snprintf std::snprintf
^

..this sort of thing continues for about 3500 lines.
Again, any help would be appreciated. I'm out of my element on this Windows machine.

Compile error using cimg version 168

When I tried to build a lib written a captcha on node 4.2.0 mac os 10.11.1, an error occurred:
../native/CImg.h:175:10: fatal error: 'initializer_list' file not found
but when i use cimg version 156, it seems ok

depth method always give me "1"

Hi everyone,

I have used CImg for reading images and displaying. I have actually successfull but I have some trouble about image depth. I have an image that color depth is 24. When I read this image with

CImg image("lena.jpg");
std::cout<< image.depth() << std::endl;

image.depth() always give me "1".
Also I have tried different images and different depth images but result is always "1".
Has any idea about it?

Best Regards...

Drawing a black rectangle over an image makes it brighter

I'm trying to make an elliptical cropper, but when I draw something over an image with a color darker than {40, 40, 40}, it makes the rest of the image go brighter, and I don't know why. Do you have any ideas why this could be happening? Thanks

FFT with fftw3

Hello everyone,

It is not an issue, but I would like to understand how works FFT in CImg, especially with fftw3.
Since I am concerned about performance I've test how scales the time consumption with 3d images dimension.

That's what I measured with #define cimg_use_openmp:

[64x64x64]
FFT forward
time: 0.01979
FFT backward
time: 1.12188

[128x128x128]
FFT forward
time: 0.169748
FFT backward
time: 1.24596

[256x256x256]
FFT forward
time: 3.53858
FFT backward
time: 5.44005

 [512x512x512]
FFT forward
time: 37.2164
FFT backward
time: 44.6921

[1024x1024x1024]
FFT forward
time: 438.787
FFT backward
time: 475.132

That's what I measured with #define cimg_use_openmp and #define cimg_use_fftw3:

[64x64x64]
FFT forward
time: 0.036742
FFT backward
time: 0.032864

[128x128x128]
FFT forward
time: 0.507304
FFT backward
time: 0.478217

[256x256x256]
FFT forward
time: 5.61296
FFT backward
time: 5.07032

[512x512x512]
FFT forward
time: 44.0638
FFT backward
time: 41.7231

[1024x1024x1024]
FFT forward
time: 337.529
FFT backward
time: 333.753

It's not obvious that fftw3 improves performances, especially for small images. Should it ? What should I know about it ?

Sorry if it's not the right place to post this message... but I don't know where it has to be else.

note: times are in sec
note: I compiled fftw with3.3.4 --enable-openmp --with-combined-threads options

How to save large tif files ?

Hello,

I've a segmentation fault error when saving large tif file. The saving process write (float) image up to 8.6go and crash, (unsigned char) image up to 2.2go and crash. It works fine with smaller files and I don't have any problem by using RAW format with large files.
Any idea to solve my problem ? is it a libtiff issue ? (Btw I used #define cimg_use_tiff and libtiff.so.5).

Best regards,

Add Dithering and Color reduce functions

Hi, I need image manipulation functions, which are not yet included in CImg:

  • ordered dithering
  • reduce color from RGB888 to RGB656 (the lower data would be cut away, internal buffer would stay 24bpp - but the stored image would be much smaller.)

The code for those operations (combined) should be pretty straightforward:

static const uint8_t rgb565_matrix[64] = {
    0, 4, 1, 5, 0, 4, 1, 5,
    6, 2, 7, 3, 6, 2, 7, 3,
    1, 5, 0, 4, 1, 5, 0, 4,
    7, 3, 6, 2, 7, 3, 6, 2,
    0, 4, 1, 5, 0, 4, 1, 5,
    6, 2, 7, 3, 6, 2, 7, 3,
    1, 5, 0, 4, 1, 5, 0, 4,
    7, 3, 6, 2, 7, 3, 6, 2
};

/* Dithering by individual subpixel */
#define MIN(a,b) (((a)<(b))?(a):(b))

// indexed dithering 888->565
static void dither_rgb888_to_rgb565_in_place_indexed(unsigned char *src, int w, int h) {
  int i = 0;
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      uint8_t tresshold_id = ((y & 7) << 3) + (x & 7);
      src[i]   = MIN(src[i]   + rgb565_matrix[tresshold_id], 0xff) & 0xF8;
      src[i+1] = MIN(src[i+1] + rgb565_matrix[tresshold_id], 0xff) & 0xFC;
      src[i+2] = MIN(src[i+2] + rgb565_matrix[tresshold_id], 0xff) & 0xF8;
      i += 3;
    }
  }
}

Any chance to add those functions (I guess they need to be splited to up to make sense).

BR
Michael

Failed to allocate memory

Hello everybody.
Actually, I was wondering about the error : Cimg::CImg(): Failed to allocate memory(797.3Mio) for image ...
I open an image using cimg_library::CImg imgIn("1.jpg");
then i create a new image cimg_library::CImg imgOut;
and use a function that return an image and initialize it by using CImg ret(inSize_width, inSize_height,1,3); (with inSize_width and inSize_height the size of the image given in parameters). But i keep having this error.
Do you know why?

load_tiff()

Hello,

using cimg_use_tiff and where test.tif is a 3d image (made with unsigned char and save with cimg)

CImg<unsigned char> img("test.tif");

img contains only the first slice of test.tif.

when

CImg<float> img("test.tif");

img contains whole slices of test.tif.

Non-free image data in CImg

In the file examples/img/CImg_demo.h, there is at least one file that is non-free: the picture of Lenna (similar to this one from Wikipedia).

According to the Linux distribution Fedora, that sort of file cannot be shipped in Fedora. There is an open bug about the subject.

I plan to repackage the tarball of CImg without examples/CImg_demo.cpp and the corresponding CImg_demo.h, but that would be a lot easier if that picture was not part of the distribution of CImg. Can you consider removing it from CImg, and distribute it by another way?

the integration of Cimg in dev c++

i am a total beginner student in image processing,and i ahve to do a project related to it,i chose Cimg as best library for it,but i wanted to know if just sending the header file here is all i need to do to integrate it,why is imageMagick++ also mentioned?
http://prntscr.com/9r0yqr

Compilation error

Hello,
Using gradle build system, with MinGW gcc 4.8.1, on windows 7
I get the following error message

See file:///C:/Users/Documents/GitHub/ZNoise/build/tmp/compileDebugExamplesExecutableExamplesCpp/output.txt for all output for compileDebugExamplesExecutableExamplesCpp.
compiling example_01.cpp failed.
In file included from C:\Users\Documents\GitHub\ZNoise\src\examples\cpp\example_01.cpp:2:0:
C:\Users\Documents\GitHub\ZNoise\src\cimg\headers/CImg.h: In function 'FILE* cimg_library::cimg::fopen(const char*, const char*)':
C:\Users\Documents\GitHub\ZNoise\src\cimg\headers/CImg.h:4725:35: error: '_fileno' was not declared in this scope
           if (_setmode(_fileno(res),0x8000)==-1) res = 0;

This is my compiler flags

-x
c++
-c
-std=c++11
-I
C:\\Users\\Documents\\GitHub\\ZNoise\\src\\examples\\headers
-I
C:\\Users\\Documents\\GitHub\\ZNoise\\src\\cimg\\headers
-I
C:\\Users\\Documents\\GitHub\\ZNoise\\src\\znoise\\headers
-m32

Any idea on what is going on ?

[clang] error: no matching member function for call to '_save_tiff'

Trying to compile with clang (version 3.4.1 on FreeBSD), it fails:

In file included from use_tiff_stream.cpp:52:
In file included from ../CImg.h:9196:
../plugins/tiff_stream.h:105:39: error: no matching member function for call to '_save_tiff'
cimg_forZ(*this,z) get_slice(z)._save_tiff(tif,z,compression_type,0,0);
~~~~~~~~~~~~~^~~~~~~~~~
use_tiff_stream.cpp:70:39: note: in instantiation of member function 'cimg_library::CImg::save_tiff' requested here
CImg imgOut = imgIn.save_tiff(&outFile, 2U);
^
../CImg.h:48567:20: note: candidate function template not viable: requires 7 arguments, but 5 were provided
const CImg& _save_tiff(TIFF *tif, const unsigned int directory, const unsigned int z, const t& pixel_t,
^
../CImg.h:48625:20: note: candidate function not viable: requires 6 arguments, but 5 were provided
const CImg& _save_tiff(TIFF *tif, const unsigned int directory, const unsigned int z,

Remark: it's OK with Gcc 4.8.

Request: add jpeg parsing directly to YCbCr (without color conversion)

When loading a YCbCr jpeg image (a.k.a. YUV), it would be really nice to have a way to get the Y and chroma components without the double color conversion (YCbCr -> RGB -> YCbCr).
On images with chroma subsampling (e.g. almost all jpegs in existence) the double color conversion degrades quality. I know it's not visually significant, but I'm doing image analysis, and it's worsening the jpeg artifacts.

P.S. you can take a look at libjpeg-turbo (https://github.com/libjpeg-turbo/libjpeg-turbo) - they have functions for loading directly to YCbCr - both into a single channel and to multiple buffers.
thanks.

Resolution tiff tags

I need to set the tiff tags: resolution unit, resolution x, and resolution y.
Looking at the code of save_tiff in CImg.h I see that:

  • TIFFTAG_RESOLUTIONUNIT is always set to RESUNIT_NONE
  • TIFFTAG_XRESOLUTION is set to 1.0f / voxel_size[0]
  • TIFFTAG_YRESOLUTION is set to 1.0f / voxel_size[1],

I define:
const char* img_fname = "Image.tif";
const unsigned int img_compression = 0; //no compression
const float img_voxel_size[] = { 0.02, 0.02, 0.0 }; //resolution x, y = 50 pixels/unit
const char* img_description = "Image Description";

and, after generating the image, I store it with:
img_map.save_tiff(img_fname, img_compression, img_voxel_size, img_description);

The tags I get (with AWare Systems AsTiffTagViewer 2.00) are:
ImageWidth (1 Short): 919
ImageLength (1 Short): 5613
BitsPerSample (1 Short): 16
Compression (1 Short): Uncompressed
Photometric (1 Short): MinIsBlack
FillOrder (1 Short): Msb2Lsb
ImageDescription (18 ASCII): Image Description
StripOffsets (1404 Long): 16, 7368, 14720, 22072, 29424, 36776, 44128,...
Orientation (1 Short): TopLeft
SamplesPerPixel (1 Short): 1
RowsPerStrip (1 Short): 4
StripByteCounts (1404 Long): 7352, 7352, 7352, 7352, 7352, 7352, 7352,...
XResolution (1 Rational): 50
0 (0 NoType):
1 (10328190 NoType):
1 (1 NoType):
1 (1 NoType):
5 (10328198 NoType):

so XResolution is OK, but then, it seems to be some kind of memory error.

My questions are:

  1. Could it be a bug, or am I doing anything wrong?
  2. Would it be possible to give more flexibility to save_tiff and to allow it to set some other tags (as with libtiff), as: RESOLUTIONUNIT, ORIENTATION, and PHOTOMETRIC?

throws exception randomnly

I have a code which loads an image file, writes to a pixel in the image and saves the image.
Some pixels are written successfully. But sometime before the loop ends, CImg throws an exception,

*** cmg::fopen(): Failed to open file 'kalyan.bmp' wih mode 'wb'.

My code snippet is as follows:

void FrameBuffer::writePixelToImage(int x, int y, Color c)
{
std::cout << "Kalyan! in writePixelToImage" << endl;

string str = _filename;
CImg <unsigned char> outPutImage;
outPutImage.load(str.c_str());

std::cout << "Kalyan! after loading in writePixeltoImage" << endl;
std::cout << "x: " << x << " y: " << y << endl;

    outPutImage(x, y, 0, 0) = c.red;
outPutImage(x, y, 0, 1) = c.green;
outPutImage(x, y, 0, 2) = c.blue;

std::cout << "Kalyan! after writing color in writePixeltoImage" << endl;

outPutImage.save(str.c_str());

}

the writePixelToImage is called several times in a loop.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.