Had some time today to think about it, and ended up with a new command -at_quadrangle
in latest G’MIC 2.1.0.
at_quadrangle:
x0[%],y0[%],x1[%],y1[%],x2[%],y2[%],x3[%],y3[%],_interpolation,
_boundary_conditions |
x0[%],y0[%],z0[%],x1[%],y1[%],z1[%],x2[%],y2[%],z2[%],x3[%],y3[%],z3[%],
_interpolation,_boundary_conditions
Retrieve pixels of the selected images belonging to the specified 2d or 3d quadrangle.
'interpolation' can be { 0=nearest-neighbor | 1=linear | 2=cubic }.
'boundary_conditions' can be { 0=dirichlet | 1=neumann | 2=periodic | 3=mirror }.
Example: [#1] image.jpg params=5%,5%,95%,5%,60%,\
95%,40%,95% --at_quadrangle $params polygon.. 4,$params,0.5,255
This is a bit more flexible than the original request, as this command is able to ‘crop’ 2d or 3d image data from an arbitrary quadrangle.
For instance :
$ gmic volumes/reference.inr --at_quadrangle 0,0,0,100%,0,100%,100%,100%,100%,0,100%,0
gives these two images (input image first, then crop by quadrangle):


I’ve used one the diagonal plane to define the quadrangle.
I guess this should be easy to use this with custom coordinates to adapt it for a quadrangle that is a given plane with an orientation.
Also, I’ve added a new filter using command -at_quadrangle
in the G’MIC plug-in. Does the same kind of crop, but limited to 2d images in this case.
What do you think ?