diff --git a/CImg.h b/CImg.h
index 54da20a9dc8f836038081358dfff6f39878cc593..74e2f7e0d376281ae5aa22e13179ec2e9311deed 100644
--- a/CImg.h
+++ b/CImg.h
@@ -19119,7 +19119,7 @@ namespace cimg_library_suffixed {
               arg1 = p1 = compile(ss5,s1,depth1,ref,is_single);
               s2 = ++s1; while (s2<se1 && (*s2!=',' || level[s2 - expr._data]!=clevel1)) ++s2;
               arg2 = compile(s1,s2,depth1,ref._data + 7,is_single);
-              arg3 = ~0U; arg4 = arg5 = 1;
+              arg3 = arg4 = arg5 = ~0U;
               if (s2<se1) {
                 s3 = ++s2; while (s3<se1 && (*s3!=',' || level[s3 - expr._data]!=clevel1)) ++s3;
                 arg3 = compile(s2,s3,depth1,0,is_single);
@@ -19129,12 +19129,18 @@ namespace cimg_library_suffixed {
                   arg5 = s1<se1?compile(++s1,se1,depth1,0,is_single):1;
                 }
               }
-              if (_cimg_mp_is_vector(arg1) && !ref[0]) ++arg1;
+              if (_cimg_mp_is_vector(arg1)) {
+                if (!ref[0]) ++arg1;
+                else if (ref[0]>=4 && arg4==~0U) arg4 = scalar1(mp_image_whd,ref[1]);
+              }
               if (_cimg_mp_is_vector(arg2)) {
                 if (arg3==~0U) arg3 = constant(_cimg_mp_size(arg2));
                 if (!ref[7]) ++arg2;
+                if (ref[7]>=4 && arg5==~0U) arg5 = scalar1(mp_image_whd,ref[8]);
               }
               if (arg3==~0U) arg3 = 1;
+              if (arg4==~0U) arg4 = 1;
+              if (arg5==~0U) arg5 = 1;
               _cimg_mp_check_type(arg3,3,1,0);
               _cimg_mp_check_type(arg4,4,1,0);
               _cimg_mp_check_type(arg5,5,1,0);