Re: Detecting a greyscale image
Bob Friesenhahn <[email protected]> Thu, 15 Jan 2009 09:42:18 -0600 (CST)
| Newsgroups | gmane.comp.video.graphicsmagick.core |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 15 Jan 2009, Nguyen Vu Hung wrote: > Hello, > I think I didn't make myself clear. > Let's take this snip code. > Magick::Image isGray;isGray.type(MagickLib::TrueColorMatteType);isGray.modifyImage();Magick::Pixels view(isGray);for(i = 0; i < Y; i++) for(j = 0; j < X; j++) *(view.get(j, i, 1, 1)) = some randome Magick::Color; > Now, how can I tell if the image "isGray" is really grayor does it contains at least one color pixel. > For example, if isGray contains a pixel #FF0000 (red),then it is not a gray image. As I previously explained, the type() method inspects the image to determine its characteristics. If the return value is BilevelType, GrayscaleType, or GrayscaleMatteType, then the image pixels are all 'gray'. Do you have evidence that this is not the case? Bob > > On Wed, Jan 14, 2009 at 2:17 AM, Bob > Friesenhahn<[email protected]> wrote:> On Tue, 13 Jan > 2009, Nguyen Vu Hung wrote:>>> Hi all,>> Suppose that I have an RGB( > or ARGB) imageand I have to detect that if it is a "true" color > imageor a grayscale image.>> By "detect", I mean that I have to look > at the image's RGB values,not by naked eyes.>> Fail positive is > acceptable if the probability of such is low.>> We can do it after > or before color quantization (using GM'sImage.quantize() API).>> I > have no idea how to do it at the moment so my question may sound > vogue.>> It seems that you are using Magick++. At the C API level, > there are> the IsGrayImage(), GetImageType(), and > GetImageCharacteristics()> functions. Out of these, it seems that > only GetImageType() is exposed> via the Magick++ API (image.type() > method). I just checked, and> bilevel and grayscale are considered > prior to palette so if the> returned type is BilevelType, > GrayscaleType, or GrayscaleMatteType,> then the image is gray.>> > Bob> ======================================> Bob Friesenhahn> ====================================== Bob Friesenhahn [email protected], http://www.simplesystems.org/users/bfriesen/ GraphicsMagick Maintainer, http://www.GraphicsMagick.org/ ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword