bugGNU Octave - Bugs: bug #36820, imread doesn't consider opacity in...

 
 

bug #36820: imread doesn't consider opacity in Magick::BilevelType, Patch included

Submitted by:  Andreas Weber <andy1978>
Submitted on:  Tue 10 Jul 2012 08:37:48 AM UTC  
 
Category: LibrariesSeverity: 3 - Normal
Priority: 5 - NormalItem Group: None
Status: FixedAssigned to: None
Originator Name: Andreas WeberOpen/Closed: Closed
Release: devOperating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 02 Aug 2013 06:22:44 PM UTC, comment #4:

I found a method to access the original image type as reported by libpng (the library that GraphicsMagick uses for reading png files). I believe that is fixed with cset 73a3c1580974.

Carnë Draug <carandraug>
Project Member
Tue 30 Jul 2013 12:07:57 PM UTC, comment #3:

I have fixed part of this problem. With cset 95055b814d35 it now reads the alpha channel correctly.

However, the actual image cannot be a MxNx3 matrix because the image is not a RGB image. Even Matlab documentation says that a grayscale image should be MxNx1 so I don't know why it's returning something different.

As GraphicsMagick reports the image as Bilevel, we must return a matrix of size MxN or pick some other strategy.

Should this bug be closed?

Carnë Draug <carandraug>
Project Member
Wed 11 Jul 2012 08:47:42 AM UTC, comment #2:

This is the output of matlab:

  • In contrast to octave, matlab returns a 600x800x3 (RGB) matrix instead of a 600x800x1 graylevel
  • alpha channel is size 600x800 and corresponds to the image opacity but is "inverted" to graphicsmagick: 0=transparent, 255=opaque. Therefore mean(alpha)=255-249.34=5.66

btw, the original image was created with inkscape and then downscaled.

Andreas Weber <andy1978>
Project Member
Wed 11 Jul 2012 08:00:09 AM UTC, comment #1:

I don't think it's that easy. The image rect.png was probably created with MS-Paint and has 1-bit gray-depth and 8-bit opacity-depth:

So I think the image (rectangles, A-D) seen with gimp or any other viewer like eog is only in the alpha channel. Nevertheless

Should the return the "seen image" in var alpha but

I will create some PNG test-images with gimp and MS-Paint for the different image types (RGB, grayscale,bilevel, with or without alpha channel), write some test-scripts and suggest a patch the next week.

greetings, Andy

Andreas Weber <andy1978>
Project Member
Tue 10 Jul 2012 08:37:48 AM UTC, original submission:

$hg id
c3fd61c59e9c+ tip

I've attached an image "rect.png" of type Magick::BilevelType. When imread in octave, the return value is empty(all zero):

output of gm identify

In _magick_read_.cc:220 there is a switch for BilevelType and GrayscaleType. Afterwards, the red channel of PixelPacket is read but it looks to me taht instead opacity should be used (red is always zero) when type==BilevelType. The attached patch solves my problem but I'm not really sure about the side effects.

Perhaps we can include some small sample images of various types and run some tests against them?

Andy

Andreas Weber <andy1978>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #26174:  rect.png added by andy1978 (9KiB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by andy1978 (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 02 Aug 2013 06:22:44 PM UTCcarandraugStatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Tue 10 Jul 2012 08:37:48 AM UTCandy1978Attached File-=>Added rect.png, #26174
      Attached File-=>Added magick_read_BilevelType_opacity.patch, #26175

    Back to the top


    Powered by Savane 3.1-cleanup1