-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a boolean operator that performs bitwise boolean operations between images #501
Conversation
Get VIPS Boolean operatoin type from string | ||
*/ | ||
VipsOperationBoolean GetBooleanOperation(std::string opStr) { | ||
if(opStr == "and" ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rather handy vips_enum_from_nick
function should allow this to be simplified:
return static_cast<VipsOperationBoolean>(
vips_enum_from_nick(nullptr, VIPS_TYPE_OPERATION_BOOLEAN, opStr.data())
);
I've added a few comments inline, thanks for this Matt. |
I took a crack at the "passing as a vector of buffers" improvement you suggested. I stored the node name and buffer size so its easier to iterate over the vector in the constructor. I think, since the constructor runs in the main thread, we could get away without storing the buffer length, but I thought I would avoid the ambiguity. |
AsyncQueueWorker(new PipelineWorker(callback, baton, queueListener, bufferIn, overlayBufferIn)); | ||
|
||
std::vector<BufferContainer> saveBuffers; | ||
saveBuffers.push_back({"bufferIn", bufferIn, baton->bufferInLength}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we only append buffers to the vector where their length is >0 then we don't need to store the length.
@lovell I tried a couple of methods of finding a pointer that is constant between the constructor and I think this is going a little off topic from the boolean operator. Can we merge this one, and then work out a better system for passing in buffers to be saved in a later commit? I would like to be able to reference this mechanism, whatever it is, in a future commit to pass buffers in for other operators that take images. |
Thank you Matt! |
This pr adds a
boolean
operator to sharp that takes a second input image, and performs a selected bitwise boolean operation on a pixel-per-pixel basis between the two images.boolean
accepts both files and buffers, much likeoverlayWith
, and uses the same boolean operators asbandbool
. It relies on the underlying vips functionboolean
, which handles casting data types and padding the right-hand operand with zeros to match the size of the left-hand operand.