IPCV - please update help page for imread

Hello,

out of curiousity installing Scilab 2026 and the latest IPCV version I find that the help page for imread might benefit from a small update.

Especially the use of the different modes.

Current help page:

modes: imread mode to be specified for different image format

Just later down it is mentioned:

The imread mode can be controlled by setting any of these optional arguments to 1:

I wonder if it could be possible to move this information to the “modes” section.

Thats aside, it took me while a while to figure out that the optional argument IMREAD_ANYDEPTH

can be set not only to 1 (grayscale), but also 3 (RGB), 4 (RGBA).

This is not mentioned in the help page at all.

Indeed 2 is also possible, but it seem to give the same result as 3…in fact it seems that all integers are possible, even negative ones … -1 creates the same result as 4. Funny enoughIMREAD_ANYDEPTH= 10000 reduces the image size from 256x256 to 64x64

To play around with the settings, I use this script:

img = imread(fullpath(getIPCVpath()+"/images/puffin.png"),IMREAD_ANYDEPTH  = 4);
[H W CH] = size(img)

f = figure();
f.figure_position = [20,20];
f.background = 8;           

if(CH == 1)
    f.figure_size = [400,411]
    imshow(img);
    a = gca();
    a.x_label.text = "image";
else
    f.figure_size = [1500,411];
    
    subplot(1,CH+1,1)
    imshow(img);
    a = gca();
    a.x_label.text = "image";

    subplot(1,CH+1,2)
    imshow(img(:,:,1));
    a = gca();
    a.x_label.text = "R";

    subplot(1,CH+1,3)
    imshow(img(:,:,2));
    a = gca();
    a.x_label.text = "G";

    subplot(1,CH+1,4)
    imshow(img(:,:,3));
    a = gca();
    a.x_label.text = "B";

    if(CH==4)
        subplot(1,CH+1,5)
        imshow(img(:,:,4));
        a = gca();
        a.x_label.text = "A"
    end

end

Cheers, Philipp

Hello,

You can open a PR at GitHub - tanchinluh/IPCV: Scilab Image Processing and Computer Vision Module with your doc updates.

S.

Hello,

I do understand that GitHub is the place for distributed/shared coding, but I am not familiar with this platform.

I figurePR stands for pull request but how would I do this?

Do I need to create a fork?

If yes, from which version?

Would you like to have a direct change in imread.xml ?

Thank you,

Philipp

You can directly edit the file IPCV/help/en_US/Image Reading, Display and Exploration/imread.xml at master · tanchinluh/IPCV · GitHub, a fork will be created on-the-fly.

S.

However, I think that imread.xml on master branch does not need any fix, the optional arguments should only take value 1, hence you don’t have to play with other values. Loading the image as RGBA (if alpha channel does exists) is triggered by IMREAD_UNCHANGED=1 (see below):

   <para>
The imread mode can be controlled by setting any of these optional arguments to 1:
   </para>
   <para>
IMREAD_UNCHANGED (return the loaded image as is (with alpha channel, otherwise it gets cropped). Ignore EXIF orientation)
   </para>
   <para>
IMREAD_GRAYSCALE (convert image to the single channel grayscale image)
   </para>
   <para>
IMREAD_COLOR (convert image to the 3 channel color image)
   </para>
   <para>
IMREAD_ANYDEPTH (return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit)
   </para>
...

… the optional arguments should only take value 1 …

I guess this is true for most optional arguments, since I did not play around will all of them.

However here is a counter example: IMREAD_ANYDEPTH

img = imread(fullpath(getIPCVpath()+“/images/puffin.png”),IMREAD_ANYDEPTH = 1);

size(img) –> 256 x 256 matrix // grayscale image

img = imread(fullpath(getIPCVpath()+“/images/puffin.png”),IMREAD_ANYDEPTH = 3);

size(img) –> 256 x 256 x 3 matrix // RGB image

img = imread(fullpath(getIPCVpath()+“/images/puffin.png”),IMREAD_ANYDEPTH = 4);

size(img) –> 256 x 256 x 4 matrix // RGBA image

Note: puffin.png is a 32 bit image

So, to load the image using IMREAD_ANYDEPTH one would have to use IMREAD_ANYDEPTH = 4 to get all image channels.

Also: Since IPCV depends on openCV, I guess the functionality is inherited from openCV.

(e.g.: IPCV mimics openCV one-to-one)

Having a look at

it seems that a lot of flags can differ from “1”.

Furthermore the doc-page states:

IMREAD_ANYDEPTH (return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit)

That’s exactly what the openCV help mentions, however:

Isn’t it either 8, 24 or 32 bit … 8 bit / channel?

All the best,

Philipp