Mercurial > octave-nkf
comparison libinterp/dldfcn/__magick_read__.cc @ 20373:a7770c66cb3d
Saturated red channel on RGB image, makes imread() return logical (bug #41584)
* libinterp/dldfcn/__magick_read__.cc (get_depth): this function tries to
second guess GM when reporting the actual bitdepth of an image in the file
(see comments for full discussion). We assumed we could check only red
from RGB but if the channel was saturated, it would return depth of 1, so
we really need to check all 3 channels. Unfortunately, 3 saturated channels
may still lead to images incorrectly read as logical.
* scripts/image/imread.m: add test for this bug.
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Fri, 10 Jul 2015 16:46:24 +0100 |
parents | a9574e3c6e9e |
children | 5b8e4f668c53 |
comparison
equal
deleted
inserted
replaced
20372:8e056730f27c | 20373:a7770c66cb3d |
---|---|
113 // Anyway, using depth() seems that only causes problems for binary | 113 // Anyway, using depth() seems that only causes problems for binary |
114 // images, and the problem with channelDepth() is not making set them | 114 // images, and the problem with channelDepth() is not making set them |
115 // all to 1. So we will guess that if all channels have depth of 1, | 115 // all to 1. So we will guess that if all channels have depth of 1, |
116 // then we must have a binary image. | 116 // then we must have a binary image. |
117 // Note that we can't use AllChannels it doesn't work for this. | 117 // Note that we can't use AllChannels it doesn't work for this. |
118 // Instead of checking all of the individual channels, we check one | 118 // We also can't check only one from RGB, one from CMYK, and grayscale |
119 // from RGB, CMYK, grayscale, and transparency. | 119 // and transparency, we really need to check all of the channels (bug #41584). |
120 static octave_idx_type | 120 static octave_idx_type |
121 get_depth (Magick::Image& img) | 121 get_depth (Magick::Image& img) |
122 { | 122 { |
123 octave_idx_type depth = img.depth (); | 123 octave_idx_type depth = img.depth (); |
124 if (depth == 8 | 124 if (depth == 8 |
125 && img.channelDepth (Magick::RedChannel) == 1 | 125 && img.channelDepth (Magick::RedChannel) == 1 |
126 && img.channelDepth (Magick::GreenChannel) == 1 | |
127 && img.channelDepth (Magick::BlueChannel) == 1 | |
126 && img.channelDepth (Magick::CyanChannel) == 1 | 128 && img.channelDepth (Magick::CyanChannel) == 1 |
129 && img.channelDepth (Magick::MagentaChannel) == 1 | |
130 && img.channelDepth (Magick::YellowChannel) == 1 | |
131 && img.channelDepth (Magick::BlackChannel) == 1 | |
127 && img.channelDepth (Magick::OpacityChannel) == 1 | 132 && img.channelDepth (Magick::OpacityChannel) == 1 |
128 && img.channelDepth (Magick::GrayChannel) == 1) | 133 && img.channelDepth (Magick::GrayChannel) == 1) |
129 depth = 1; | 134 depth = 1; |
130 | 135 |
131 return depth; | 136 return depth; |