MAGICK_QUANTIZE: Incorrect number of argument

Help
2011-10-18
2013-06-03
  • Daniel Molina
    Daniel Molina
    2011-10-18

    Hello,

    When I do

         READ_JPEG, filename, image, /GRAYSCALE, /TWO_PASS_QUAN

    or simply

         READ_JPEG, filename, image, /GRAYSCALE

    I obtain

      % LOADCT: Loading table B-W LINEAR
      % MAGICK_QUANTIZE: Incorrect number of arguments.
      % Error occurred at: READ_JPEG           96 /home/lluvia/My_Programs/share/gnudatalanguage/lib/read_jpeg.pro
      %                    BINARIZE            53 Binarize.pro
      %                    $MAIN$         
      % Execution halted at: BINARIZE            53 Binarize.pro

    However,

      READ_JPEG, filename, image

    don't give me errors

    Which can be the problem?

    Cheers

     
  • Daniel Molina
    Daniel Molina
    2011-10-20

    I'd like knowing an alternative way of doing the "/GRAYSCALE, /TWO_PASS_QUAN" thing.

     
  • Daniel Molina
    Daniel Molina
    2011-10-21

    I'm trying to debug it by myself.

    According to read_jpeg.pro

    ;;DITHER if necessary                                                                                
    if (KEYWORD_SET(grayscale)) then begin
        MAGICK_QUANTIZE, mid, /GRAYSCALE
    endif else begin
       if (KEYWORD_SET(colors)) then begin
          if ((colors LT 8) OR (color GT 256)) then MESSAGE, "COLORS must be in the range 8 to 256"
          if (KEYWORD_SET(two_pass_quantize)) then MESSAGE, "TWO_PASS_QUANTIZE not supported by ImageMagi\
    ck."
          MAGICK_QUANTIZE, mid, colors, dither=dither
       endif
    endelse

    there is no chance with /TWO_PASS_QUANTIZE at the moment. However, it is not finally messaged because the error happens before.  /TWO_PASS_QUANTIZE is only in the /grayscale cycle, so, happens just nothing if you write

      READ_JPEG, filename, image, /TWO_PASS_QUANTIZE

    ? Is it the wished behavior? Maybe if it has no another use without grayscale, I have no idea, but then the user could be noticed that that had no effect.

    Also, anything wrong is happening with /GRAYSCALE. I'm reading magick_cl.cpp which has  void magick_quantize(EnvT* e) in line 913. I know almost nothing about c++, but I'd like to debug it if no one do it before. Which functions can I write for stoping the execution or give some feedback about where is placed the error? A kind of printf.

     
  • Alain C.
    Alain C.
    2011-10-27

    in c++ code ? You may try

    cout << "here " << value << endl;

    if complain, adding
    #include <stdio.h>
    in the begin of the code (please check, <> or "")

     
  • Daniel Molina
    Daniel Molina
    2011-10-31

    I'm trying to debug it. I added some "waypoints" for checking.

      void magick_quantize(EnvT* e)
      {
        try{
          cerr << "I'm here(0)." << endl;
          size_t nParam=e->NParam(2);// HERE!                                                   
          cerr << "I'm here(0.2)." << endl;
          DUInt mid;
          cerr << "I'm here(0.4)." << endl;
          e->AssureScalarPar<DUIntGDL>(0,mid);
          Image image=magick_image(e,mid);
          DLong ncol;
          //set the number of colors;                                                                    
          cerr << "I'm here(1)." << endl;
          if(!e->KeywordSet(0))
            {
              if(nParam>1)
                e->AssureLongScalarPar(1,ncol);
              else
                  ncol=256;

              image.quantizeColors(ncol);
              if(e->KeywordSet(1))//YUV                                                                  
                image.quantizeColorSpace(YUVColorspace);
              else if(e->KeywordSet(2))//Grayscale                                                       

               {cerr << "I'm here(2)." << endl;
                  image.quantizeColorSpace(GRAYColorspace);}
              else
                image.quantizeColorSpace(RGBColorspace);
              if(e->KeywordSet(3))
                image.quantizeDither(true);
              image.quantize();
              image.classType(PseudoClass);
            }
          else
            {
              //truecolor                                                                                
              if(nParam>1)
                e->AssureLongScalarPar(1,ncol);
              else
                ncol=256;

              image.quantizeColors(ncol);
              image.quantizeColorSpace(RGBColorspace);
              image.quantizeColors((long)256*(long)256*(long)256-1);
              if(e->KeywordSet(3))
                image.quantizeDither(true);
              image.quantize();
              image.classType(DirectClass);

            }

          cerr << "I'm here(magick_replace)." << endl;
          magick_replace(e,mid,image);
        }
        }
        catch (Exception &error_ )
          {
            cerr << "I'm here(catch)." << endl;
            e->Throw(error_.what());
          }
      }

    If I don't change anything, execution ends in

    % Compiled module: READ_JPEG.
    I'm here(0).
    % MAGICK_QUANTIZE: Incorrect number of arguments.
    % Error occurred at: READ_JPEG           96 /home/lluvia/My_Programs/share/gnudatalanguage/lib/read_jpeg.pro
    %                    $MAIN$         
    % Execution halted at: BINARIZE            53 binarize.pro

    but if I change the 5 line of the code I posted to

          size_t nParam=e->NParam(1);

    I go forward until another error which has to be fixed, but which seems to have a different origin (see post "failing when charging a particular PNG image":  https://sourceforge.net/projects/gnudatalanguage/forums/forum/338692/topic/4786290)

    GDL> READ_JPEG, filename, image, /GRAYSCALE
    % Compiled module: READ_JPEG.
    I'm here(0).
    I'm here(0.2).
    I'm here(0.4).
    I'm here(1).
    I'm here(2).
    I'm here(magick_replace).
    % MAGICK_READINDEXES: (FIXME!) Magick's getIndexes() returned NULL for: MID
    % Error occurred at: READ_JPEG          109 /home/lluvia/My_Programs/share/gnudatalanguage/lib/read_jpeg.pro
    %                    $MAIN$         
    % Execution halted at: $MAIN$ 

    So, maybe it is the key, although I cannot check it since I have another problem in this machine.

     
  • Alain C.
    Alain C.
    2011-11-09

    solved in the CVS

    thanks for the bug report

    if similar problems, please submit bug report with simplest way to reproduce them

     
  • Daniel Molina
    Daniel Molina
    2011-11-16

    Thank you very much!
    It is working!