Comments (5)
Well, if I understand well, you will get this kind of issues with all the CImg<T>::get_*()
method, or is it specific to warp()
?
from cimg.
I haven't really dug that deep to see if this is a general issue with all get_
methods, so I'd assume you're correct. I focused on warp
because that's the one in particular we were more worried about in terms of performance.
The question still stands: would such a patch be welcomed? I wouldn't be able to provide a patch for all get_
methods, in case you worry about maintaining full consistency, but maybe ths could be a start. Maybe I could have also named do_warp
as get_warp
and make it an overload instead of bringing a new name into the mix.
from cimg.
Considering that it is not really a issue with the get_warp()
method, I doubt such a patch is the solution.
Maybe we can think about a more general (and elegant) solution that could apply to all get_*()
methods instead.
from cimg.
Thanks @dtschump for that feedback. I agree that this is a wider problem and not specific to the warp
function.
OTOH I don't think there's a solution that will allow you to offer this functionality in a generic way for all functions, given how their outputs' sizes depend so heavily on the input values of each operation. If anything, I think the "generic" solution would be something along the lines of implementing three variants for each method, just like there are two at the moment:
CImg<T> &op(a, b, c); // inline
CImg<T> get_op(a, c, b); // new instance
void get_op(CImg<T> &out, a, c, b); // raw operation
This is obviously a big effort that I wouldn't be able to undertake, and probably neither would you without some clear incentive. If that's the situation, and you'd want to have an all-or-nothing solution, then I'll stick to my patch on our local copy; otherwise if you would consider adding this functionality on a function-by-function basis then I'd be happy to upstream this patch, and others that might come.
from cimg.
I do actually think there is a generic solution.
Maybe this can be a good start. The example below apply some CImg methods on buffers manually allocated.
All temporary allocations that may happen will be freed by CImg destructors.
#include "CImg.h"
using namespace cimg_library;
int main(int argc, char **argv) {
// Allocate memory for input image.
const int width = 512, height = 512, depth = 1, spectrum = 3;
const float *p_in = new float[width*height*depth*spectrum];
// Allocate memory for output image.
const float *p_out = new float[width*height*depth*spectrum];
// Call a CImg method to fill values in 'p_in'.
CImg<float>(p_in,width,height,depth,spectrum,true).rand(0,255);
// Call a method so that p_out contains the resulting image.
// All temporary allocations will be freed by CImg.
CImg<float>(p_out,width,height,depth,spectrum,true) =
CImg<float>(p_in,width,height,depth,spectrum,true).get_blur(10);
// Display result.
CImg<float>(p_out,width,height,depth,spectrum,true).display();
// Free memory.
delete[] p_in;
delete[] p_out;
return 0;
}
Wouldn't it be something like this that you are looking for?
from cimg.
Related Issues (20)
- Support for BGR image interleaved. HOT 3
- Cant find how to include modules without errors in the header files.
- get_MAT returns empty Mat
- ImageMagick: CImg.h: In member function 'cimg_library::CImg<T>& cimg_library::CImg<T>::load_magick(const char*)':
- Explicit instantiation bug of `CImgList` HOT 1
- CVE-2024-26540: heap-buffer-overflow in load_analyze(...) HOT 5
- Lanczos versus cubic interpolation
- Reading DNG file with libRaw and passing it to Cimg HOT 1
- Documentation error - Bezier to Hermite conversion
- Making function next(), and back(). Basically, they use nexttoward. HOT 1
- Alpha-Aware Resize HOT 1
- Is it really necessary to specify pattern? HOT 1
- Binary literal bug. HOT 4
- Buffer Overflow in get_load_jpeg_buffer HOT 1
- compile error in the .h file on Visual Studio 2022 HOT 1
- Convert planar RGBA to interleaved.
- Prefer to use magick rather than convert
- Turn Off Coordinate Info in Display HOT 2
- Was the v.3.4.0 tag moved? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cimg.